// create a controller
UIViewController* controller = [[UIViewController alloc] init];
// create a view
UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
// add the view to the controller
[controller.view addSubview:webView];
// create a navigation controller
UINavigationController *navBar=[[UINavigationController alloc]initWithRootViewController:webviewController];
// create a button
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithCustomView:...];
// set the bar button
[navBar.navigationItem setLeftBarButtonItem:button];
// *** most important one
// add the button to the navigation item of the controller and
// not to the navigation controller
[webviewController.navigationItem setLeftBarButtonItem:button];
// present view controller
[self.navigationController presentViewController:navBar animated:YES completion:^{
}];
Leave a Reply