在子视图中获取父视图的控制器

/**
 * 
获取父视图的控制器
 *
 *  @return
父视图的控制器
 */

- (
UIViewController *)viewController
{
   
for ( UIView * next = [ self superview ]; next; next = next. superview ) {
       
UIResponder *nextResponder = [next nextResponder ];
       
if ([nextResponder isKindOfClass :[ UIViewController class ]]) {
           
return ( UIViewController *)nextResponder;
        }
    }
   
return nil ;
}

//跳转
[[ self viewController ]. navigationController pushViewController :platDetailVC animated : YES ];

你可能感兴趣的:(父子控制器)