search

Home  >  Q&A  >  body text

objective-c - 从一个view到ViewControllert之间跳转的方法?



就像这样在红包里(一个view)点击查看领取详情(按钮),跳转到一个viewcontroler,这个跳转一般怎么写?

淡淡烟草味淡淡烟草味2882 days ago559

reply all(2)I'll reply

  • PHPz

    PHPz2017-04-26 09:04:04

    -(UIViewController *)viewController
    {
        UIResponder *next = self.nextResponder;
        do {
            if ([next isKindOfClass:[UIViewController class]]) {
                return (UIViewController *)next;
            }
            
            next = next.nextResponder;
        } while (next != nil);
        
        return nil;
    }
    新建一个UIView的类目,把这个方法放进去,以后就可以直接通过`view.viewController`来获取视图的控制器了。

    reply
    0
  • ringa_lee

    ringa_lee2017-04-26 09:04:04

    The interface that pops up should be a viewcontroller. You can refer to this http://stackoverflow.com/a/19564760

    reply
    0
  • Cancelreply