ios - 使用后退按钮打开网址

标签 ios url uiviewcontroller

我有个小麻烦。 我想在我的 iOS 应用程序中打开 URL。

我在网上找到的方法是:

 [[UIApplication sharedApplication] openURL:url];

它工作正常,但这种方法关闭我的应用程序并打开没有后退按钮的 safari 以返回我的应用程序。如何实现?

我想要这样的东西

   MFMessageComposeViewController * picker = [[MFMessageComposeViewController alloc] init];
   [self presentModalViewController:picker animated:YES];

最佳答案

与其在 Safari 中打开 URL,不如创建一个包含 UIWebView 的新 View Controller ?

显示 View Controller ,传入 URL,并将 URL 加载到 UIWebView 中。像这样:

MyWebViewController *mwvc = [[MyWebViewController alloc] initWithURL:myURL];
[self.navigationController pushViewController:mwvc animated:YES];

然后在 MyWebViewController:initWithURL

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:myURL]];
[myWebView loadRequest:request];

关于ios - 使用后退按钮打开网址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14498806/

相关文章:

facebook - 使用 CloudMade 和 Facebook iOs SDK 时出现重复符号 _OBJC_METACLASS_$_SBJSON

ios - '必须使用非零布局参数初始化 UICollectionView' - Swift 4

regex - 使用正则表达式验证 Youtube 播放列表 URL

ios - 如何将数据从 UIViewController 传递到嵌入在该 UIViewController 上的容器中的 UITableViewController?

ios - 如何实现利用多个 ViewController 的 UIPageViewController

ios - 如何使用共享 Storyboard设计加载正确的 UIViewController?

android - WebView 打开应用/默认浏览器

http - 如果 http ://is missing,使用 url.ResolveReference() 解析错误的 URL

javascript - 使用正则表达式从 JavaScript 中的 URL 中删除 utm_* 参数

ios - iPhone 7或7 Plus使用becomeFirstResponder出现严重白屏bug