iPhone:以编程方式打开网址

问题描述:

我是iPhone新手。
我想在我的应用程序中打开一个URL。
我该怎么做这个任务?请建议我并提供一些有用的链接。

I am new to iPhone. I want to open an url in my application. How can I do this task? Please suggest me and provide some useful link.

更新(2016):最好的方法现在这样做是为了实例化并呈现一个SFSafariViewController。这为用户提供了Safari的安全性和速度,并且可以访问他们可能已经设置的任何Cookie或Safari功能,而无需离开您的应用。

Update (2016): The best way to do this nowadays is to instantiate and present an SFSafariViewController. This gives the user the security and speed of Safari, and access to any cookies or Safari features they may already have set without having to leave your app.

如果您想要在Safari中打开URL(并退出应用程序),您可以使用 uURpplication的openURL方法

If you want to open the URL in Safari (and exit your application) you can use the openURL method of UIApplication

如果您希望在应用内部处理它,请使用WKWebView。

If you'd rather have it handled inside of your app, use WKWebView.