2009-08-19 48 views

回答

0

您可以使flipside視圖成爲UINavigationController的一個子類。

或者,如果您只需要導航欄,而無需推送/彈出新的視圖控制器,並且從NIB加載翻轉視圖,則只需在NIB文件中添加一個導航欄即可。

0

您的應用程序委託頭文件(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 

您的應用程序委託.m文件(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

看起來像一個非常好的解決方案!但是我有麻煩讓它工作。什麼是'rootViewController'?我會想象它是根視圖控制器,但是不是說它應該首先以某種方式實現嗎?我有麻煩調用像你描述的方法使用'[(MyAppDelegate *)[UIApplication sharedApplication] .delegate showSettings]''。我試着用UIApplication.sharedApplication.delegate.showSettings切換它,但仍然沒有任何運氣......希望你能幫忙,因爲看起來這是我最有可能去的解決方案 - 如果我能使它工作。 – 2009-12-23 17:00:45