uitableView didSelectRowAtIndexPath“所选行未加载详细信息视图” [英] uitableView didSelectRowAtIndexPath "selected row not loading the detail view"

查看:102
本文介绍了uitableView didSelectRowAtIndexPath“所选行未加载详细信息视图”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含7行的表视图,我想点击我的行并加载detailView(uiViewController)

I have a table view with 7 rows, I want to click on my rows and load the detailView( uiViewController )

我可以选择行,我可以看到登录控制台,但它永远不会加载详细信息视图

I can select the row and I can see the Log in console but it never loads the detail view

请给我一些点击,有什么问题?

would you please give me some hits, what is the problem?

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSLog(@"selected rows");

MyBookDetailView *c = [[MyBookDetailView alloc] init];

[self.navigationController popToRootViewControllerAnimated:NO];
[self.navigationController pushViewController:c animated:YES];
}

我也尝试使用performSelectorOnMainThread,但它仍然只是可点击而且我有加载我的问题查看控制器,我还添加了委托 - (void)viewDidLoad方法,

I also try performSelectorOnMainThread but still it just clickable and I have problem to load my view controller, I also add delegate in - (void)viewDidLoad method,

提前致谢!

lates代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{


[tableView deselectRowAtIndexPath:indexPath animated:YES];
MyBookDetailView *c = [[MyBookDetailView alloc] initWithNibName:@"MyBookDetailView" bundle:nil];

[self.navigationController pushViewController:c animated:YES];

}


推荐答案

为什么你想要将带有导航控制器堆栈的所有控制器弹出到根控制器,同时想要推送新的MyBookDetailView(我希望它的基类是UIViewController)。

Why you want to pop up all controllers withing navigationcontroller stack to root controller and same time your want to push up new MyBookDetailView (i hope its base class is UIViewController).

无论如何, MyBookDetailView * c = [[MyBookDetailView alloc] init]; 也不适合你。因为UIViewController(MyBookDetailView)视图的 c 对象是nil。我建议使用断点跟踪执行堆栈和您尝试删除的变量,并在运行时添加,您将更好地了解程序中发生了什么。

Anyways, MyBookDetailView *c = [[MyBookDetailView alloc] init]; also will not work for you. Because c object of UIViewController (MyBookDetailView) view is nil. I recommend use break point trace execution stack and variable that you trying to remove and adding on run time you will better know what going on in your program.

我认为以下代码可能适合您,

I think following code may work for you,

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    MyBookDetailView *c = [[MyBookDetailView alloc] initWithNibName:@"WriteYourNibNameIfYouCreate" bundle:nil];

    [self.navigationController pushViewController:c animated:YES];
}

这篇关于uitableView didSelectRowAtIndexPath“所选行未加载详细信息视图”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆