I know this is extremely silly.
I have a view controller that scans a QR code. I create it in the AppDelegate (didFinishLaunchingWithOptions), and I also set my AppDelegate as a delegate for the the view controller which will call a method when he finishes scanning the code. In that method, that I have implemented in the AppDelegate I want to present a UINavigationController. The problem is that it is not presenting my navigation controller. This is my code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
reader=[ZBarReaderViewController new];
reader.readerDelegate=self;
reader.supportedOrientationsMask=ZBarOrientationMaskAll;
ZBarImageScanner *scanner=reader.scanner;
[scanner setSymbology:ZBAR_I25 config:ZBAR_CFG_ENABLE to:0];
[self.window addSubview:reader.view];
[self.window makeKeyAndVisible];
return YES;
}
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
RootViewController *rootViewController=[[RootViewController alloc] init ]; //create root view controller
UINavigationController *navigationController=[[UINavigationController alloc] initWithRootViewController:rootViewController]; // create and init navigation controller with viewController
[navigationController setValue:[[GradientBar alloc] init] forKey:@"navigationBar"];
rootViewController.title=@"mTLU";
[reader presentModalViewController:navigationController animated:NO];
}
Seems like you forgot to set
self.window.rootViewControllerindidFinishLaunchingWithOptions:Try:
This code assumes
readerispropertyofAppDelegate. If it’s onlyiVaryou should ommitself.(or consider making it aproperty).