2011-04-09 45 views
0

我已經花了幾個小時,並嘗試了各種各樣的東西。我可以確認didSelectRowAtIndexPath確實正在運行,並且我正在查找的特定對象正在返回。新視圖沒有被加載 - 正在使用pushViewController

不做任何事的位是我試圖顯示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]; 

} 

更新:我得到了它通過使用這種機制的工作: [自我presentModalViewController:細節動畫:是];

回答

0
SensDetailViewClass *details = [[SensDetailViewClass alloc] initWithNibName:@"SensDetailViewClass" bundle:nil]; 
[self.navigationController pushViewController:details animated:YES]; 

我覺得你是如此新鮮NEDD檢查教程的鏈接

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

+0

感謝您的回答,但我不明白我必須做的。請解釋。 – 2011-04-09 08:10:41

+0

告訴我SensDetailViewClass的nibname。 – 2011-04-09 08:11:44

+0

SensDetailViewClass.xib – 2011-04-09 08:21:41

0

你確定你的SensDetailViewClass類具有MainWindow作爲其的.xib文件?

請檢查並在上面的代碼替換筆尖名`

initWithNibName:@"MainWindow" 

感謝,

+0

感謝您的回答。我在哪裏檢查?我使用XCode 4. – 2011-04-09 08:11:23

0

1)確定Y * OU具有導航審計長在應用 *或者它只是基於視圖的應用程序。

如果這是確定然後, 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]; 
+0

謝謝 - 我得到它與這種機制:[self presentModalViewController:filtersViewController animated:YES]; – 2011-04-12 11:18:34

+0

是的......但是,這不會讓你在其他網頁上移動......如果你正在尋找類似導航的東西......而presentModal從頭開始了一個新視圖。 – 2011-04-12 12:41:18

+0

我有一個UITableView中的新聞項目列表。當選擇一個時,我想顯示新聞內容。presentModal似乎能夠給我我想要的東西,只要我可以關閉視圖並返回到文章ID列表。 – 2011-04-12 18:22:41