在iOS应用程序而不是启动屏幕中启动URL

时间:2017-03-10 09:29:32

标签: ios objective-c url webview

在我的基于IOS网络的应用程序中,每次用户打开具有网址的应用程序而不是下面的启动屏幕时,我都需要启动动画:

     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {



           LaunchViewController * lvc = [[LaunchViewController alloc] initWithNibName:@"LaunchViewController" bundle:nil];

           glaunchOptions = launchOptions;

           .
           .
           .
}

    - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
    {
        NSLog(@"This is the URL" , url) ;

        BeepViewController * lvc = [[BeepViewController alloc] initWithNibName:@"BeepViewController" bundle:nil];
        UINavigationController *navVC = (UINavigationController *)self.window.rootViewController;
        if (navVC) {
            [navVC pushViewController:lvc animated:NO];
        }
        [self.window makeKeyAndVisible];
        return YES ;
    }

打开网址功能用于通过按下基于网络的按钮在我的应用程序中打开页面。 我的网址例如是:name.mobi/app/yyy.html 有什么帮助吗?

1 个答案:

答案 0 :(得分:0)

尝试阅读有关Objective-C:自定义URL方案的模式。

您应该使用此方法从URL处理打开的应用程序:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    // handler code here
}

您可以使用此方法显示屏幕:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *root = [[UINavigationController alloc]initWithRootViewController:[storyboard instantiateViewControllerWithIdentifier:@"BeepViewController"]];
self.window.rootViewController= root;

要打开网址,请使用以下代码段:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.path.com"]];