[英]Switch between native view and hybrid webview in iOS
I have 3 files "AppDelegate.m", "MainViewController.m" and "ViewController.m" 我有3个文件“ AppDelegate.m”,“ MainViewController.m”和“ ViewController.m”
In "AppDelegate.m" file, I have this function: 在“ AppDelegate.m”文件中,我具有以下功能:
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
self.viewController = [[MainViewController alloc] init]; //line1
return [super application:application didFinishLaunchingWithOptions:launchOptions]; //line2
//return YES; //line3
}
When I run the above function it shows the "hybrid view" but when I comment the line1, line2 and uncomment the line3 it shows the "native view". 当我运行上面的函数时,它显示“混合视图”,但是当我注释第1行,第2行并取消注释第3行时,它显示“本机视图”。
How can I call the line3 "native view" on click of a button function which is created in a file abc.m in subfolder of the project and vice-versa. 单击在项目子文件夹中的abc.m文件中创建的按钮功能时,如何将line3称为“本机视图”,反之亦然。
NOTE: "MainViewController.m" file have hybrid view and "ViewController.m" have native view. 注意:“ MainViewController.m”文件具有混合视图,而“ ViewController.m”文件具有本机视图。
Just tick is initial View Controller after selecting MainViewController
选择MainViewController之后,只需勾选初始View Controller
Or Use This Code 或使用此代码
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"MainViewController"];
[[UIApplication sharedApplication].keyWindow setRootViewController:vc];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.