当前位置: 移动技术网 > 移动技术>移动开发>IOS > iOS 自定义View 中跳转UIViewController

iOS 自定义View 中跳转UIViewController

2018年03月10日  | 移动技术网移动技术  | 我要评论

iOS 自定义View 中跳转UIViewController

自定义View中实现控制器的跳转,可以有多种实现方式:

1 使用Notification

使用Notification,在父控制器打开需要跳转的控制器

2 使用代理

使用代理通知父控制器跳转

3 使用闭包

原理同第2条

4 使用主窗口的根控制器

拿到主窗口的根控制器,用根控制器打开需要跳转的控制器

Swift

  let nav = UIApplication.shared.keyWindow?.rootViewController as! UIViewController
  let feedVC  = FeedBackViewController.init()
  nav.present(feedVC!, animated: true, completion: nil)

OC

    UIViewController *root = [UIApplication sharedApplication].keyWindow.rootViewController;
    [root presentViewController:<#(nonnull UIViewController *)#> animated:YES completion:nil];

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网