从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;
}

 

posted @ 2016-04-11 13:10  heyode  阅读(1004)  评论(0编辑  收藏  举报