UITableViewCell点击不能push解决方法

一般情况下不能push是因为当前控制器没有导航控制器,造成不能push的情况.

解决方法如下:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSLog(@"点击left-%d",(int)indexPath.row);
    NSLog(@"%@",self.navigationController);
    TempViewController *tempVc = [[TempViewController alloc]init];
    UINavigationController *navVC = [UIApplication sharedApplication].keyWindow.rootViewController.childViewControllers[0].navigationController;
    [navVC pushViewController:tempVc animated:YES];
}

还有什么好的解决方式,请大神告知哟..嘻嘻~~~

原文地址:https://www.cnblogs.com/pengsi/p/6855309.html