美文网首页设计模式,持久化,页面切换
如何在UIView里跳转ViewController

如何在UIView里跳转ViewController

作者: 不会学习的睿睿 | 来源:发表于2016-08-08 16:43 被阅读312次

在开发中,经常在一个UIViewController(AViewController)弹出一个UIView,再从UIView跳转到另一个控制器(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的点击方法里:

-(void)BtnClick{
  BViewController * bviewcontroller = [[AViewController alloc] init];
    [self. viewcontroller.navigationController pushViewController: bviewcontroller  animated:YES];
}

之后在AViewcontroller 弹出UIVew处,写上

view.viewcontroller=self;

相关文章

网友评论

本文标题:如何在UIView里跳转ViewController

本文链接:https://www.haomeiwen.com/subject/llsrsttx.html