没有加载新视图 - 我正在使用pushViewController

时间:2011-04-09 06:00:09

标签: iphone uiview xib pushviewcontroller

我花了好几个小时,尝试了各种各样的事情。我可以确认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:详细动画:是];

3 个答案:

答案 0 :(得分: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/

答案 1 :(得分:0)

您确定SensDetailViewClass班的{。}}文件有MainWindow吗?

请检查并替换笔尖名称

initWithNibName:@"MainWindow"  

在上面的代码中

谢谢,

答案 2 :(得分:0)

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

如果这样可以,那么, 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];