1. Add following method in .m file
-(void)backToMain:(id)sender
{
ViewController *toHome =[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
[self presentModalViewController:toHome animated:YES];
}
UINavigationBar *naviBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 44)];
naviBar.delegate = self;naviBar.tintColor = [UIColor blueColor];
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(backToMain:)];
UINavigationItem *naviItem = [[UINavigationItem alloc] init];
naviItem.leftBarButtonItem = backItem;naviBar.items = [NSArray arrayWithObjects:naviItem, nil];
[self.view addSubview:naviBar];
1. Add following method in .h file
-(IBAction) backToMain:(id)sender;
No comments:
Post a Comment