I installed navController, which appears after clicking a button. However, if I click the button, I get the error: " Warning: Attempt to present <UINavigationController>: 0xab5d9d0 on <MyApp: 0xadaa320> whose view is not in the window hierarchy! "
Does anyone know how to solve this? I also tried something on Stackoverflow, but this is not my solution.
Here is my code to open the navigation controller:
I donβt know if anyone knows this photo gallery, but if you do not, here is a project.
My code (MyApp.m):
#import MyApp.h ... //some stuff - (void)launchGalleryView { MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self]; // Set browser options. browser.wantsFullScreenLayout = YES; browser.displayActionButton = NO; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:browser]; NSMutableArray *photos = [[NSMutableArray alloc] init]; MWPhoto *photo; photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"callculator" ofType:@"jpg"]]; photo.caption = @"The calculator is soo beateful..."; [photos addObject:photo]; self.photos = photos; [self presentModalViewController:navController animated:NO]; }
Thanks in advance.
Edit:
it is in the sources and in the compilation sources, but in the resources you can see that it is red (storyboard). Maybe this is due to this?
Second .h controller:
@class MyApp; @interface Second : UIViewController <MWPhotoBrowserDelegate> { } @property (nonatomic, retain) MyApp* vC; @end
Secnond.m controller:
MyApp.h:
#import "Second.h" @interface myApp : UIViewController <MWPhotoBrowserDelegate> { } -(void)launchGalleryView; NSArray *_photos;

NEW EDITING:
I found that I need to call the "launchGalleryView" method in viewDidAppear, but how can I do this without calling navcontroller every time the view loads? Does anyone know how to do this?
source share