Appdelegate presentviewcontroller

时间:2016-03-04 08:43:12

标签: ios rootviewcontroller

我尝试使用以下内容显示网页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 个答案:

答案 0 :(得分:1)

我认为这应该有效:

@PostConstruct
void initFieldTwo(){
  field2="prefix"+field1;
}

答案 1 :(得分: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;
    }

答案 2 :(得分:0)

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

SFSafariViewController

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

示例1: iOS-SafariViewControllerFinishedProject

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

您也可以从github下载Demo Project。 IOS9SafariViewControllerTutorial Example

修改: -

我为你做了演示 没有故事板。请查看以下链接。

<强> Safari without storyboard demo

输出: -

enter image description here

答案 3 :(得分:0)

SafariViewController演示代码移至viewDidAppear的{​​{1}}。如果您的RootViewControllerRootViewController,请将其移至导航控制器UINavigationController的{​​{1}}