全て、
簡単に事前に決定するのではなく、検索時に注釈ピンのタイトル内にユーザー検索の場所の名前を表示する方法を決定しようとしています。ユーザーが場所を入力する検索バーの現在のコードは次のとおりです。
- (IBAction) showAddress
{
[addressField resignFirstResponder];
CLLocationCoordinate2D location = [self addressLocation];
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta=0.2;
span.longitudeDelta=0.2;
region.span=span;
region.center=location;
[mapView setRegion:region animated:TRUE];
[mapView regionThatFits:region];
MapViewAnnotation *addAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"" andCoordinate:location];
[self.mapView addAnnotation:addAnnotation];
}
タイトル情報を以下に宣言します。
@implementation AddressAnnotation
@synthesize _name;
-(id)initWithName:(NSString*)name address:(NSString*)address coordinate:(CLLocationCoordinate2D)coordinate {
if ((self = [super init]))
{
_name = [name copy];
}
return self;
}
-(NSString *)title
{
if ([_name isKindOfClass:[NSNull class]])
return @"Unknown charge";
else
return _name;
}
@end
私の理解では、initWithTitleをtitle変数名に置き換える必要がありますが、私の質問はそれがどのように見えるかであり、ユーザーによるこれらのカスタム検索のタイトルを表示するのに十分ですか?
ありがとうございました!!グレッグ