在開發(fā)中,經(jīng)常在一個(gè)UIViewController(AViewController)彈出一個(gè)UIView,再從UIView跳轉(zhuǎn)到另一個(gè)控制器(BViewController),但是在UIView中是沒有以下的的一些方法的。
[self.navigationController pushViewController: animated: ];
[self.navigationController popViewControllerAnimated:];
[self presentViewController: animated: completion: ];
[self dismissViewControllerAnimated: completion:];
所以可以這樣做,在UIView的H文件中,添加
@property (nonatomic,strong) UIViewController * viewcontroller;
之后在M文件的button的點(diǎn)擊方法里:
-(void)BtnClick{
BViewController * bviewcontroller = [[AViewController alloc] init];
[self. viewcontroller.navigationController pushViewController: bviewcontroller animated:YES];
}
之后在AViewcontroller 彈出UIVew處,寫上
view.viewcontroller=self;