Skip to content

Instantly share code, notes, and snippets.

@Dimillian
Created July 20, 2012 19:54
Show Gist options
  • Save Dimillian/3152851 to your computer and use it in GitHub Desktop.
Save Dimillian/3152851 to your computer and use it in GitHub Desktop.
Inject UI in phonegap
- (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