美文网首页iOS 开发之路
iOS 如何在UITableViewCell中直接弹出警示框

iOS 如何在UITableViewCell中直接弹出警示框

作者: Roadsourth | 来源:发表于2017-12-28 15:39 被阅读166次

项目需要,不借助代理,block等,直接在cell中处理点击事件。

需要先获取cell所在的控制器,然后就可以操作你想要的。

- (UIViewController *)getSuperController{

    UIViewController *vc = [[UIViewController alloc]init];

    for (UIView* next = [self superview]; next; next = next.superview

{

               UIResponder* nextResponder = [next nextResponder];

              if ([nextResponder isKindOfClass:[UIViewController class]])

 {

                   vc = (UIViewController*)nextResponder;

               break;

        }

    }    

    return vc;

}

相关文章

网友评论

    本文标题:iOS 如何在UITableViewCell中直接弹出警示框

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