嗨,我想使UINavigationController但不是在mainViewController(第一viewControllerClass),我需要把UINavigationController放在第二類。但是,如果我將這些代碼寫入appDelegate.mUINavigationController在任何其他類
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
// [window addSubview:[navigationController view]];
UINavigationController *navigation = [[UINavigationController alloc]initWithRootViewController:self.viewController];
self.window.rootViewController = navigation;
[self.window makeKeyAndVisible];
return YES;
}
然後UINavigationController出現在mainView中。我試圖把它放在其他類一樣,
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// strWhichTaleOnScreen=[masivTaleNames objectAtIndex:indexPath.row];
NSString *selectDay;
[email protected]"first string";
NSLog(@"selecDay=%@",selectDay);
classDetailOfMessagesViewController *nesneDetailOfMessagesViewController = [[classDetailOfMessagesViewController alloc] initWithNibName:@"classDetailOfMessagesViewController" bundle:nil];
nesneDetailOfMessagesViewController.selectDay = selectDay;
[navigation pushViewController: nesneDetailOfMessagesViewController animated:YES];
nesneDetailOfMessagesViewController = nil;
}
但它不工作,我想我在這第二視圖中創建RootViewController的,但我不知道怎麼辦。 如果有人能指示我解決問題,我會很高興。
是的,感謝您的糾正。我添加了導航=(UINavigationController *)self.window.rootViewController;在「viewDidLoad」方法,然後我可以達到「classDetailOfMessagesViewController」的「initWithNibName」方法,但無法達到「viewDidLoad」,你有一個想法,爲什麼? –
好吧,我解決了這個問題,我的錯誤是與presentModalView去二等。據我瞭解,我必須去每個xib與pushViewController UINavigationController。 –
推送和現在模態有不同的用法。如果你想展示相關的東西(例如新聞的細節),你應該推動detailsviewcontroller。現在的模式更適合不合情理的東西。 – cekisakurek