0

我为此花了几个小时,并尝试了各种方法。我可以确认 didSelectRowAtIndexPath 确实正在运行,并且正在返回我正在寻找的特定对象。

没有做任何事情的部分是我试图显示 SensDetailViewClass 视图的部分。它运行代码,但是 SensDetailViewClass.m 中的 viewDidLoad 方法没有运行,视图也没有改变。

我想显示 SensDetailViewClass。我可以确认 .xib 文件的所有者是 SensDetailsViewClass。

请帮忙。这是代码。

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

// get the selected item
Sens *info = [_sensInfos objectAtIndex:indexPath.row];

// initialise the detail view controller and display it
SensDetailViewClass *details = [[SensDetailViewClass alloc] initWithNibName:@"MainWindow" bundle:nil];

// set the title of the page
[details setTitle:info.heading];

details.selectedSens = info;

[self.navigationController pushViewController:details animated:YES];
[details release];

}

更新:我通过使用这种机制让它工作:[self presentModalViewController:details animated:YES];

4

3 回答 3

0

你确定你的SensDetailViewClass 班级有MainWindow它的 .xib 文件吗?

请检查并替换笔尖名称`

initWithNibName:@"MainWindow"  

在上面的代码中

谢谢,

于 2011-04-09T06:07:07.120 回答
0

1 ) 你确定你*你在应用程序中有导航控制器*或者它只是基于视图的应用程序。

如果这没问题,那么,2)

// initialise the detail view controller and display it
SensDetailViewClass *details = [[SensDetailViewClass alloc] initWithNibName:@"You-Xib name for this View" bundle:nil];

// set the title of the page
[details setTitle:info.heading];

details.selectedSens = info;

[self.navigationController pushViewController:details animated:YES];
[details release];
于 2011-04-09T09:31:18.127 回答
0
SensDetailViewClass *details = [[SensDetailViewClass alloc] initWithNibName:@"SensDetailViewClass" bundle:nil];
[self.navigationController pushViewController:details animated:YES];

我觉得你比较新鲜,所以需要检查教程的链接

http://www.icodeblog.com/2008/08/03/iphone-programming-tutorial-transitioning-between-views/

于 2011-04-09T06:02:26.530 回答