Reputation: 1245
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSError *error = nil;
NSString *username = [[NSUserDefaults standardUserDefaults] objectForKey:@"username"];
NSString *str = [SFHFKeychainUtils getPasswordForUsername:username andServiceName:@"mybibleapp" error:&error];
NSLog(@"previous un");
NSLog(@"%@", str);
if(str != nil)
{
main_page *detailViewController = [[main_page alloc] initWithNibName:@"main_page" bundle:nil];
// Pass the selected object to the new view controller.
// detailViewController.localStringtextnote = localStringtextnote;
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
When I put this code for navigating to main_page it shows an error that property navigationController not found on object of appdelegate
so i put this code insted of the above
main_page *log = [[main_page alloc] initWithNibName:@"main_page" bundle:nil];
[window addSubview:tabController.view];
[window addSubview:log.view];
[window makeKeyAndVisible];
the page is redirected to main_page but nothing is working in this way. no navigation in main_page is working, I cant redirect any page from the main_page. So what can I do to solve these errors.
Upvotes: 1
Views: 184
Reputation: 7082
You can create a "proxy" viewController without nib which is loaded in MainWindow's navigationController and then do something like the following, in the proxy's viewDidLoad
NSError *error = nil;
NSString *username = [[NSUserDefaults standardUserDefaults] objectForKey:@"username"];
NSString *str = [SFHFKeychainUtils getPasswordForUsername:username andServiceName:@"mybibleapp" error:&error];
NSLog(@"previous un");
NSLog(@"%@", str);
UIViewController *controller;
if (!error && nil != str) {
controller = [[DetailViewController alloc] init];
} else {
controller = [[LoginViewController alloc] init];
}
[[self navigationController] pushViewController:controller animated:YES];
[controller release];
Upvotes: 1
Reputation: 9544
Initial page loading is usually handled in the MainWindow.xib nib. You shouldn't have to manually load it.
Try creating a new project from a template and then do in and look at how the appDelegate and MainWindow.xib are setup.
Upvotes: 0