在cell中实现跳转

1.先重写uiviewcontrol的方法
- (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;
}

2.接下来是点击cell的方法
-(void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath{
[[self viewController]presentViewController:VC animated:YES completion:nil];
}

你可能感兴趣的:(OC基础知识)