2009-08-19 4 views

Antwort

0

Sie könnten die umgekehrte Ansicht eine Unterklasse von UINavigationController machen.

Oder, wenn Sie einfach die Navigationsleiste benötigen, ohne neue Ansichts-Controller zu drücken/pop und die umgekehrte Ansicht von einer NIB geladen wird, fügen Sie einfach eine Navigationsleiste in die NIB-Datei ein.

0

Ihre Anwendung delegieren Header-Datei (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 

Ihre Anwendung delegieren .m-Datei (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]; 
} 
+0

Scheint wie eine wirklich schöne Lösung! Aber ich habe Probleme, damit es funktioniert. Was ist 'rootViewController'? Ich würde mir vorstellen, dass es der View-Controller für die Wurzel ist, aber würde das nicht bedeuten, dass es zuerst irgendwie implementiert werden sollte? Und ich habe Probleme beim Anrufen der Methoden, die Sie mit '[(MyAppDelegate *) [UIApplication sharedApplication] .delegate showSettings]' beschrieben haben. Ich habe versucht, es mit UIApplication.sharedApplication.delegate.showSettings zu wechseln, aber immer noch ohne Glück ... Hoffe, du kannst helfen, denn es scheint, als ob dies die Lösung ist, für die ich am wahrscheinlichsten bin - wenn ich es zum Laufen bringen kann. –

Verwandte Themen