在GooGle地图上添加UITextField和UiButton [英] Adding UITextField and UiButton on GooGle map

查看:159
本文介绍了在GooGle地图上添加UITextField和UiButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS新手并使用 Google Map SDK 并且能够在视图上显示地图但现在

I'm new to iOS and working on Google Map SDK and able to show the map on the view but now


  1. 我想添加一个 UITextField 并在那里输入位置

  2. 点击按钮点击该位置应显示在地图中

  1. I want to add a UITextField and enter the location over there
  2. On buttons click that location should be shown in the map

所以请帮助我。

推荐答案

我建议您在 UINavigationBar 上添加按钮,或者在地图视图顶部放置 UIToolBar ,然后通过点击它显示一个带有文本字段的UIAlertView接收输入,并在按下警报确定后,输入输入的位置并执行您的操作。不要在地图上添加按钮,这会降低可用性因素。

I would suggest you to add buttons on the UINavigationBar or by placing a UIToolBar on the top of the map view and then by clicking on it show a UIAlertView with textfield that takes in the input and after the alert's ok is pressed take the location entered and do your stuff. Don't add buttons on the map,it would bring down the usability factor.

如果您已经有导航栏,请试试这个

If you have a navigation bar already, try this

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

这篇关于在GooGle地图上添加UITextField和UiButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆