简体   繁体   English

从iPhone应用程序打开URL

[英]Open a URL from iPhone Application

I want to integrate some links on my iPhone application. 我想在我的iPhone应用程序中集成一些链接。

That is when the user touches on the button saying "Yahoo" then Yahoo's page will be opened and then all the functionalities of Yahoo mail has proceeds. 就是说,当用户触摸说“ Yahoo”的按钮时,Yahoo的页面将被打开,然后Yahoo Mail的所有功能将继续进行。 How can I do that? 我怎样才能做到这一点? I have a bit of idea about NSURL, but not much. 我对NSURL有一点想法,但不多。 Please help me for that. 请帮我。 Thanks in advance.. 提前致谢..

To open the page in Mobile Safari, you need to implement something like the following: 要在Mobile Safari中打开页面,您需要实现以下内容:

NSURL *url = [NSUR URLWithString:@"http://www.google.com"];
[[UIApplication sharedApplication] openURL:url];

You could return to your application using Custom URL Schemes (for more information see the iPhone Application Programming Guide ), but since you want to access sites over which you have no control, I presume that isn't an option? 您可以使用“ 自定义URL方案”返回到您的应用程序(有关更多信息,请参阅《 iPhone应用程序编程指南》 ),但是由于您想访问无法控制的网站,因此我认为这不是一种选择吗? Could you use a UIWebView control within your app instead? 您可以在应用程序中使用UIWebView控件吗?

在目标的操作方法中输入以下内容:

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://www.google.com"]];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM