xcode - 使用 Objective-C 的 SFSafariViewController

标签 xcode safari xcode7 keychain

使用 Objective-C 实现 SFSafariViewController 的最佳方法是什么。我目前有一个 UITableView,每个都指向不同的网站。我可以知道如何使用 Objective-C 而不是 Swift 对它们中的每一个进行编码以在 SFSafariViewController 中加载不同的网站吗?提前致谢!

最佳答案

这将适用于较新的版本,例如 10。

NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"http://google.com"]];
if ([SFSafariViewController class] != nil) {
    SFSafariViewController *sfvc = [[SFSafariViewController alloc] initWithURL:URL];
    [self presentViewController:sfvc animated:YES completion:nil];
} else {
    [[UIApplication sharedApplication] openURL:URL];
}

关于xcode - 使用 Objective-C 的 SFSafariViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33593670/

相关文章:

swift - 仅在真实设备上出现 NSExtensionPointIdentifier 错误

ios - 发现不支持的资源(不是目录、文件或符号链接(symbolic link)的东西)- xcode 7.2

iphone - 验证可用的网络连接和启用定位服务以使用应用程序

html - SVG 使用元素引用外部文件在 Safari 中不起作用

ios - 应用内 Safari 浏览器是否支持附属链接的 cookie?

javascript - 带有自定义按钮的 tinymce-4 在 Chrome 和 Firefox 中工作正常但在 Safari 中不起作用 - 为什么?

c++ - iOS 13 崩溃 - 回溯不可用

c - 在 Xcode 中构建 C MEX 文件时链接库时出现问题

swift - 如何对在 Swift 中调用的私有(private)方法进行单元测试

swift - 快速编程中点击的图像区域的坐标