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

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

posted on 2017-05-15 10:34  玉思盈蝶  阅读(546)  评论(0编辑  收藏  举报

导航