Created
July 20, 2012 19:54
-
-
Save Dimillian/3152851 to your computer and use it in GitHub Desktop.
Inject UI in phonegap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)webViewDidStartLoad:(UIWebView *)theWebView | |
{ | |
if (firstLaunch) { | |
firstLaunch = NO; | |
//As phonegap overwrite the main UI privately this method is used as the entry point to inject custom UI | |
//Phonegap nib are loaded and displayed, so safe to move them to another view | |
[self injectCustomUI]; | |
} | |
return [ super webViewDidStartLoad:theWebView ]; | |
} | |
-(void)injectCustomUI | |
{ | |
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults]; | |
if (standardUserDefaults) { | |
if (![standardUserDefaults objectForKey:KEY_SERVER_ADDRESS]) { | |
[standardUserDefaults setObject:DEFAULT_SERVER_ADDRESS forKey:KEY_SERVER_ADDRESS]; | |
} | |
} | |
HomeScreenController *settingVC = [[HomeScreenController alloc]initWithNibName:@"HomeScreenView" | |
bundle:nil]; | |
//Here we inject custom UI, we set our new navigation controller as the root view controller instead of the phonegap view controller. | |
//Phonegap view controller will be added later on the stack of the navigation controller. | |
UINavigationController *navigationVC = [[UINavigationController alloc]initWithRootViewController:settingVC]; | |
navigationVC.navigationBar.hidden = YES; | |
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
self.window.rootViewController = navigationVC; | |
[self.window makeKeyAndVisible]; | |
[self setGestureOnWebView]; | |
[self reloadBaseAddress]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment