Does anyone know how to create a Navigation View inside a standard Flipside View to read and update settings? If so, can you post some code on doing this.
You could make the flipside view a subclass of UINavigationController.
Or, if you simply require the navigation bar, without the need to push/pop new view controllers and the flipside view is being loaded from a NIB, then just add a navigation bar in the NIB file.
Your application delegate header file (MyAppDelegate.h):
@interface MyAppDelegate : NSObject <UIApplicationDelegate> {
IBOutlet UIWindow *window;
// We're assuming the root view for the main view is connected to this outlet of the app delegate
// It'll probably have a different class than UIViewController in your app
IBOutlet UIViewController *mainViewController;
UINavigationController *settingsNavigationController;
}
// Other view controllers can do [(MyAppDelegate *)[UIApplication sharedApplication].delegate showSettings] to show the settings
- (void)showSettings;
- (void)hideSettings;
@end
Your application delegate .m file (MyAppDelegate.m):
- (void)showSettings
{
// Load the settings view controller the first time it's needed
// We're assuming you created the root view controller for the settings in a nib called SettingsRootViewController.xib. You might also just create the root view programmatically (maybe by subclassing UITableViewController)
if(settingsNavigationController == nil)
{
SettingsRootViewController *settingsRootViewController = [[[SettingsRootViewController alloc] initWithNibName:@"SettingsRootViewController" bundle:nil] autorelease];
settingsNavigationController = [[UINavigationController alloc] initWithRootViewController:settingsRootViewController];
settingsNavigationController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal
}
[rootViewController presentModalViewController:settingsNavigationController animated:YES];
}
- (void)hideSettings
{
[settingsNavigationController dismissModalViewController:YES];
}
@Jacques:
Seems like a really nice solution! But I'm having troubles making it work. What is rootViewController
? I would imagine it was the view controller for the root, but wouldn't
that mean it should be implemented somehow first?
And I'm having troubles calling the methods like you discribed using [(MyAppDelegate *)[UIApplication sharedApplication].delegate showSettings]
. I tried switching it with UIApplication.sharedApplication.delegate.showSettings but still without any luck...
Hope you can help, 'cous it seems like this is the solution, I'll most likely go for - if I can make it work.
- Mikkel