1

私はiOSGoogle Map SDKが初めてで、ビューにマップを表示できるように取り組んでいますが、今は

  1. UITextFieldを追加して、あちらの場所を入力したい
  2. ボタンをクリックすると、その場所が地図に表示されます

だから親切に私を助けてください。

4

1 に答える 1

2

UINavigationBarにボタンを追加するか、マップ ビューの上部にUIToolBarを配置し、それをクリックして、入力を受け取るテキスト フィールドを含む UIAlertView を表示し、アラートの [OK] が押された後に、入力された場所を取得して、あなたのことをしてください。地図上にボタンを追加しないでください。使いやすさの要素が低下します。

すでにナビゲーション バーがある場合は、これを試してください

UIBarButtonItem *locationButton = [[UIBarButtonItem alloc] initWithTitle:@"location" style:UIBarButtonItemStyleBordered target:self action:@selector(showAlertWithTextField)];
self.navigationItem.rightBarButtonItem=locationButton;


-(void)showAlertWithTextField{
    UIAlertView* dialog = [[UIAlertView alloc] initWithTitle:@"Enter Location" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil];    
    [dialog setAlertViewStyle:UIAlertViewStylePlainTextInput];
    [dialog show];
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 1)
        NSLog(@"%@",[[alertView textFieldAtIndex:0]text]);
}
于 2013-10-21T09:28:45.203 に答える