10
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"朱珍洁";
self.view.backgroundColor = [UIColor purpleColor];
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
button.frame = CGRectMake(100, 100, 200, 40);
[button setTitle:@"返回" forState:UIControlStateNormal];
[button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
UIButton *buyBtn = [UIButton buttonWithType:UIButtonTypeSystem];
buyBtn.frame = CGRectMake(100, 200, 200, 40);
[buyBtn setTitle:@"购买" forState:UIControlStateNormal];
[buyBtn addTarget:self action:@selector(buy) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:buyBtn];
// Do any additional setup after loading the view.
}
//跳转到登录系统
- (void)buy {
LoginViewController *loginVC = [[LoginViewController alloc] init];
UINavigationController *naVC = [[UINavigationController alloc] initWithRootViewController:loginVC];
naVC.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self.navigationController presentViewController:naVC animated:YES completion:nil];
}
//点击返回按钮返回到某一级视图控制器
- (void)back {
//1、返回到上一级视图控制器
// [self.navigationController popViewControllerAnimated:YES];
//2、返回根视图控制器
/*
[self.navigationController popToRootViewControllerAnimated:YES];*/
//3、返回到指定的视图控制器
UIViewController *vc = [self.navigationController.viewControllers objectAtIndex:1];
[self.navigationController popToViewController:vc animated:YES];
}