此應用程序是我使用UITableView的第一個應用程序,我遇到了爲什麼要向其添加詳細信息視圖的問題。 (因爲我第一次創建它時我的應用程序是「基於視圖的應用程序」,所以我必須手動執行此操作)。將詳細信息視圖添加到UITableView
這是我的表視圖的didSelectRowAtIndexPath:
代碼:
detail = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle: [NSBundle mainBundle]];
detail.delegate = self;
detail.dtitle = [titles objectAtIndex: indexPath.row];
detail.dusername = [usernames objectAtIndex: indexPath.row];
detail.dpassword = [passwords objectAtIndex: indexPath.row];
[self.navigationController pushViewController: detail animated:YES];
//[self presentViewController:detail animated:NO completion:nil];
倒數第二行是一個引起問題。我從我製作的一個空白的「主 - 細節應用程序」中複製它,但它似乎不適用於此應用程序,因爲它在另一個應用程序中。註釋掉的線是我一直在使用的地方,但並不完全是我想要的。
我能做些什麼來解決這個問題?
其次,在DetailViewController
,在我的標題欄中的後退按鈕(導航欄的導航項目,要準確)就不會出現。我是否需要添加代碼來表明此視圖是從屬視圖還是其他內容?
如果有人絆倒在這裏,這裏有這個答案的具體代碼:http://stackoverflow.com/questions/11341337/embed-navigation-controller – Greg