ajay92x
ajay92x

Reputation: 73

Switch between native view and hybrid webview in iOS

I have 3 files "AppDelegate.m", "MainViewController.m" and "ViewController.m"

In "AppDelegate.m" file, I have this function:

- (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".

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.

NOTE: "MainViewController.m" file have hybrid view and "ViewController.m" have native view.

Upvotes: 0

Views: 284

Answers (1)

Darshan Karekar
Darshan Karekar

Reputation: 681

Just tick is initial View Controller after selecting MainViewController

Or Use This Code

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"MainViewController"];

[[UIApplication sharedApplication].keyWindow setRootViewController:vc];

Upvotes: 1

Related Questions