我有一个分割视图应用程序,允许用户选择并显示所选图像的缩略图。我已经使用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的几行中添加,但是当它运行时,根视图中的表格不显示,并且不再适当地在纵向和横向视图之间切换。
我有其他代码可以随时使用,如果这有助于澄清。请让我知道! 谢谢。