(iOS/iPhone/XCode) 用于向 Safari 提交数据的文本字段和按钮
我正在尝试开发一个应用程序,但陷入了这个特定的部分。我之前通过 UIWebView 中显示的 Web 表单采取了不同的方法,但在按照我想要的方式打开它时遇到了问题。我更改了用户界面,现在想采用这种方法:
背景
用户需要能够获得前往特定商店位置的路线。 UI 包含 UIText Field 的实例和圆形矩形按钮。用户应该能够单击该按钮,然后将为用户弹出默认的地图应用程序。
我如何想象这是如何编码的:
1)用户在 textField
中输入地址 - textField
将地址存储为变量 (%var%
)
2) 用户按下Go
按钮
- 按钮将变量 (%var%
) 从 textField
添加到 URL 字符串(见下文)
- 按钮提交要在 Safari 中打开的完整 URL
3) Safari 在地图应用程序中打开请求
UI图像示例:http://i55.tinypic.com/vnjc41.jpg
http://maps.google.com/?saddr=
%var%
&daddr=123+Road+St%2C+Town%2C+CA+90210&hl=en
I'm trying to develop an application and am stuck at this specific part. I was previously taking a different approach through a web form displayed in UIWebView, but was having issues getting it to open how I wanted. I changed the UI and would now like to take this approach:
Background
User needs to be able to get directions to a specific shop location. The UI contains an instance of UIText Field and a round rect button. The User should be able to click the button and the default Maps application will pop up for the user.
How I imagine this being coded:
1) User enters address in textField
- textField
stores address as variable (%var%
)
2) User presses Go
button
- Button adds variable (%var%
) from textField
to URL string (see below)
- Button submits full URL to be opened in Safari
3) Safari opens request in Maps application
Image Example of UI: http://i55.tinypic.com/vnjc41.jpg
http://maps.google.com/?saddr=
%var%
&daddr=123+Road+St%2C+Town%2C+CA+90210&hl=en
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了一种更好的方法,使用按钮打开地图应用程序:-(
IBAction)hbgdirButton:(id)sender{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://maps.google.com/maps?q=Harrisburg+PA&hl=en"]];
}
Found a better way to do this using a button to open the maps application:
-(IBAction)hbgdirButton:(id)sender{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://maps.google.com/maps?q=Harrisburg+PA&hl=en"]];
}