總覽
此類別代表根據部分輸入字串進行完整查詢的預測。
資源 | |
NSAttributedString * | attributedFullText |
預測結果的完整說明,內容為 NSAttributedString。 | |
NSAttributedString * | attributedPrimaryText |
以 NSAttributedString 表示預測結果的主要文字,通常是地點的名稱。 | |
NSAttributedString * | attributedSecondaryText |
以 NSAttributedString 表示預測結果的次要文字,通常是地點的位置。 | |
NSString * | placeID |
表示預測結果地點 ID 的屬性,適用於 Place Details 要求。 | |
NSArray< NSString * > * | 類型 |
這項自動完成結果的類型。 | |
NSNumber * | distanceMeters |
如果在要求的 GMSAutocompleteFilter 中指定了有效的起點,則起點與預測之間的直線距離 (以公尺為單位)。 | |
相關函式 | |
(請注意,這些並非成員函式)。 | |
NSString *const | kGMSAutocompleteMatchAttribute |
「GMSAutocompletePrediction 歸因完整文字」中片段的比對屬性名稱 |
好友與相關函式說明文件
- (NSString* const) kGMSAutocompleteMatchAttribute [related] |
「GMSAutocompletePrediction
歸因完整文字」中片段的比對屬性名稱
屬性說明文件
- (NSAttributedString*) attributedFullText [read, copy] |
預測結果的完整說明,內容為 NSAttributedString。
例如:「澳洲新南威爾斯州雪梨」雪梨歌劇院。
符合使用者輸入內容的每個文字範圍都有 kGMSAutocompleteMatchAttribute
。舉例來說,您可以使用 enumerateAttribute 讓每個相符結果加上粗體:
UIFont *regularFont = [UIFont systemFontOfSize:[UIFont labelFontSize]]; UIFont *boldFont = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
NSMutableAttributedString *bolded = [prediction.attributedFullText mutableCopy]; [bolded enumerateAttribute:kGMSAutocompleteMatchAttribute inRange:NSMakeRange(0, bolded.length) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) { UIFont *font = (value == nil) ? regularFont : boldFont; [bolded addAttribute:NSFontAttributeName value:font range:range]; }];
label.attributedText = bolded;
- (NSAttributedString*) attributedPrimaryText [read, copy] |
以 NSAttributedString 表示預測結果的主要文字,通常是地點的名稱。
例如「雪梨歌劇院」。
符合使用者輸入內容的文字範圍會有 kGMSAutocompleteMatchAttribute
,例如 attributedFullText
。
- (NSAttributedString*) attributedSecondaryText [read, copy] |
以 NSAttributedString 表示預測結果的次要文字,通常是地點的位置。
例如「澳洲新南威爾斯」。
符合使用者輸入內容的文字範圍會有 kGMSAutocompleteMatchAttribute
,例如 attributedFullText
。
可能會是 Nil。
- (NSString*) placeID [read, copy] |
表示預測結果地點 ID 的屬性,適用於 Place Details 要求。
- (NSArray<NSString *>*) types [read, copy] |
這項自動完成結果的類型。
類型是 NSString,有效值是指在 <https://developers.google.com/places/ios-sdk/supported_types> 中所記錄的任何類型。
- (NSNumber*) distanceMeters [read, assign] |
如果在要求的 GMSAutocompleteFilter
中指定了有效的起點,則起點與預測之間的直線距離 (以公尺為單位)。