如何在继承于UITableViewCell的类中获取这个cell得主视图控制器

来源:互联网 发布:优米网倒闭知乎 编辑:程序博客网 时间:2024/05/17 01:01

@interface ACell :UITableViewCell

@implementation ACell


AViewController *a = (AViewController *)[self findViewController:button];

BViewController *b =[[BViewControlleralloc]init];

[a setHidesBottomBarWhenPushed:YES];

[a.navigationController pushViewController:b animated:YES];


- (UIViewController *)findViewController:(UIView *)sourceView

{

    id target=sourceView;

    while (target) {

        target = ((UIResponder *)target).nextResponder;

        if ([target isKindOfClass:[UIViewController class]]) {

            break;

        }

    }

    return target;

}



0 0