Objective c 无缝地从一个模式视图切换到另一个模式视图,而不显示纯色背景

Objective c 无缝地从一个模式视图切换到另一个模式视图,而不显示纯色背景,objective-c,ios,cocoa-touch,ipad,ios5,Objective C,Ios,Cocoa Touch,Ipad,Ios5,我的iPad应用程序有以下UI: 单击“设置”按钮时,我希望对话框水平翻转以显示“设置”对话框 我的这个很好用。但是,dailog翻转时会显示背景色。如你所见: 有没有办法在对话框翻转时不让这一块颜色可见?我希望它看起来更无缝——就像一张纸在翻转一样 这些观点基本上是这样的: 窗口 主视图。设置为窗口的rootViewController 登录模式视图 因此,主窗口和根控制器的设置如下(在app delegate类中): 登录窗口已设置并显示在主视图的ViewDidDisplay中: 当

我的iPad应用程序有以下UI:

单击“设置”按钮时,我希望对话框水平翻转以显示“设置”对话框

我的这个很好用。但是,dailog翻转时会显示背景色。如你所见:

有没有办法在对话框翻转时不让这一块颜色可见?我希望它看起来更无缝——就像一张纸在翻转一样

这些观点基本上是这样的:

窗口

主视图。设置为窗口的rootViewController

登录模式视图

因此,主窗口和根控制器的设置如下(在app delegate类中):

登录窗口已设置并显示在主视图的ViewDidDisplay中:

当按下设置按钮时:显示设置模式视图的方式与显示登录模式视图的方式基本相同:

- (IBAction)settingsButtonPressed:(id)sender {
    SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:@"SettingsView" bundle:nil];
    controller.delegate = self;
    controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    controller.modalPresentationStyle = UIModalPresentationCurrentContext;
    [self presentModalViewController:controller animated:YES];    
}

我认为没有任何方法可以使用modalPresentationStyle实现您想要的功能。您需要使用以下方法使用过渡动画自己实现动画:

+ (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion
使用UIViewAnimationOptionTransitionFlipFromLeft选项

在这种情况下,您要翻转的新视图不是模态(controller.view)的内容,而是模态框架本身,因此尝试从设置按钮调用上述方法,而不是传递controller.view,替换controller.view.superview,如果这不起作用,尝试controller.view.superview.superview,直到动画看起来正确为止


这将需要一些调整,以确定具体的操作方法。

谢谢,尼克。你的建议几乎奏效了。transitionFromView将登录模式对话框切换为设置对话框;但当显示设置时,它是全屏大小的。从较小的对话框到全屏。我认为这可能与以下事实有关:模态视图可以在其当前上下文中转换(使用上面的代码示例):controller.modalPresentationStyle=UIModalPresentationCurrentContext;
- (IBAction)settingsButtonPressed:(id)sender {
    SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:@"SettingsView" bundle:nil];
    controller.delegate = self;
    controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    controller.modalPresentationStyle = UIModalPresentationCurrentContext;
    [self presentModalViewController:controller animated:YES];    
}
+ (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion