1.自定义导航栏返回按钮
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"back" style:UIBarButtonItemStyleBordered target:self action:@selector(back)];
2.代码调用segue实现跳转
[self performSegueWithIdentifier:@"ShowRoleListSegue" sender:self];
同时可实现函数以在跳转前设置相关数据
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"ShowRoleListSegue"]) {
RoleListTableViewController *roleListTableViewController = [segue destinationViewController];
roleListTableViewController.loginData=loginData;
}
}
2.返回导航栏中上一个视图
[self.navigationController popViewControllerAnimated:YES];
3.使用故事版id实现跳转
UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"CustomerBaseInfoReadonly"];
[self.navigationController pushViewController:vc animated:YES];
4.try catch
@try
{
[self performSegueWithIdentifier:@"buyInfoDetailSegue" sender:self];
}
@catch (NSException *exception)
{
NSLog(@"Caught %@%@", [exception name], [exception reason]);
}
5.exit
- (void)exitApplication { [UIView beginAnimations:@"exitApplication" context:nil]; [UIView setAnimationDuration:0.5]; [UIView setAnimationDelegate:self]; [UIView setAnimationTransition:UIViewAnimationCurveEaseOut forView:self.window cache:NO]; [UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)]; self.window.bounds = CGRectMake(0, 0, 0, 0); [UIView commitAnimations]; } - (void)animationFinished:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { if ([animationID compare:@"exitApplication"] == 0) { exit(0); } }