0

我正在尝试使用以下内容显示网页 google.com。出于某种原因,它没有向 google.com 提供控制器。任何人都可以帮忙吗?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    SFSafariViewController *vc = [[SFSafariViewController alloc] initWithURL:[NSURL URLWithString:@"https://www.google.com"]];
    [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:vc animated:YES completion:nil];
    return YES;
}
4

4 回答 4

1

我认为这应该有效:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    SFSafariViewController *vc = [[SFSafariViewController alloc] initWithURL:[NSURL URLWithString:@"https://www.google.com"]];
    self.window.rootViewController = vc;
    return YES;
}
于 2016-03-04T08:55:58.383 回答
0

尝试这个

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

            SFSafariViewController *vc = [[SFSafariViewController alloc] initWithURL:[NSURL URLWithString:@"https://www.google.com"]];
            self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
        return YES;
    }
于 2016-03-04T08:52:29.817 回答
0

SafariViewController演示文稿代码移动到viewDidAppear您的RootViewController. 如果您RootViewController是 a UINavigationController,请将其移至viewDidAppear导航控制器的topViewController

于 2017-12-18T23:50:00.710 回答
0

如何使用 SFSafariview 控制器首先检查此链接。

SFSafariViewController

此外,您还可以在下面的链接中查看完整的教程,

示例 1:- iOS-SafariViewControllerFinishedProject

示例 2:- ios-9-getting-started-with-sfsafariviewcontroller

从 github 你也可以下载 Demo Project。IOS9SafariViewController教程示例

编辑 :-

我已经为你制作了没有故事板的演示。请检查以下链接。

没有故事板演示的 Safari

输出 :-

在此处输入图像描述

于 2016-03-04T08:56:55.070 回答