从TableviewCell中获得TableviewController的几种方式


id view = [self superview]; // 获取cell所在的tableview while (view && [view isKindOfClass:[UITableView class]] == NO) { view = [view superview]; } UITableView *tableView = (UITableView *)view; // 获取tableview的控制器 DTAcountSafeViewController * vc = (DTAcountSafeViewController *)tableView.dataSource;
-(MyView*)initWithController:(CardCreatorViewController*) aController andFrame:(CGRect)aFrame
{
    if (self = [super initWithFrame:aFrame]) 
    {
       controller = aController;
       // more initialisation here
    }

    return self;
}
原文地址:https://www.cnblogs.com/heyode/p/5377934.html