我有一個分割視圖應用程序,允許用戶選擇並顯示所選圖像的縮略圖。我已經使用Interface Builder在detailViewController中放置了一個UIButton。當按下此按鈕時,我希望將其更改爲圖像的全屏視圖。我已經建立了一個新的視圖控制器,稱爲FullViewController,並認爲我已經連接了一切。問題是導航控制器爲空。我調整了AppDelegate.m以下幾點:導航控制器爲空
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after app launch.
// Set the split view controller as the window's root view controller and display.
self.window.rootViewController = self.splitViewController;
UINavigationController *nvcontrol =[[UINavigationController alloc] initWithRootViewController:fullViewController];
[window addSubview:nvcontrol.view];
[self.window makeKeyAndVisible];
return YES;
}
這是DetailViewController.m功能按鈕被按下時調用。導航控制器在這裏顯示爲空。
//Function called when button is pressed - should bring up full screen view
- (IBAction) pressFullViewButtonFunction: (id) sender{
//viewLabel.text = @"Full View";
if (fullViewController == nil){
FullViewController *fullViewController = [[FullViewController alloc] initWithNibName:@"FullViewController" bundle:[NSBundle mainBundle]];
NSLog(@"fullViewController is %@", fullViewController);
self.fullViewController = fullViewController;
}
NSLog(@"self.navigationController is %@",self.navigationController);//this is null
[self.navigationController pushViewController:self.fullViewController animated:YES];
}
我不知道如何解決這個問題。我已經嘗試在AppDelegate的幾行中添加,但是當它運行時,根視圖中的表格不顯示,並且不再適當地在縱向和橫向視圖之間切換。
我有其他代碼可以隨時使用,如果這有助於澄清。請讓我知道! 謝謝。