创建新MYViewController : UIViewController
类initWithBackButton:(UIBarButtonItem *)backButton;
@property (nonatomic, strong) UIBarButtonItem *saveBackButton
- (id)initWithBackButton:(UIBarButtonItem *)backButton {
self = [super init];
if(self){
self.saveBackButton = backButton;
}
return self;
}
在根
创建3个属性vc1、vc2、vc3;
当你创建MYViewController
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, width, height);
[button addTarget:self action:@selector(iWantToOpenNumber2:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.vc3 = [[MYViewController alloc] initWithBackButton:backItem];
}
- (void)iWantToOpenNumber2:(id)sender {
[self dismissViewControllerAnimated: YES completion: ^{
[self presentViewController:self.vc2 animated: YES completion:^{}];
}];
}