添加的UITextField和UIButton的上谷歌地图(Adding UITextField a

2019-10-18 19:24发布

我是新来的iOS和对工作的Google Map SDK ,并能够在地图上显示的看法,但现在

  1. 我想添加一个UITextField ,并在那里输入位置
  2. 按钮上单击该位置应在地图中显示

所以,请您帮助我。

Answer 1:

我建议你添加的UINavigationBar的或放置在地图视图的顶部UIToolBar,然后按钮上按一下显示与文本框一个UIAlertView中是需要输入,并按下了警报的确定采取输入的位置后做你的东西。 不要在地图上添加按钮,它会降可用性的因素。

如果你有一个导航栏已,试试这个

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]);
}


文章来源: Adding UITextField and UiButton on GooGle map