IOS忽略ModalPresentationStyle和ModalTransitionStyle并呈现全屏

时间:2013-06-27 11:33:26

标签: ios ipad

我的应用程序完全忽略了UIModalPresentationFormSheet和U​​IModalTransitionStyleCrossDissolve。它始终弹出全屏并具有默认转换。

它在我的真实应用程序上完成。 然后,我做了一个空白测试应用程序,它做了同样的事情。

很简单: 我的AppDelegate将KBViewController加载为根视图。 KBViewController尝试呈现一个空白视图控制器(KBModalViewController)。 KBModalViewController.xib中的视图设置为“FormSheet”大小

我的视图控制器:

@implementation KBViewController


-(void)viewDidAppear:(BOOL)animated{
    [self setModalPresentationStyle:UIModalPresentationFormSheet];
    [self setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
    KBModalViewController *m = [[KBModalViewController alloc] initWithNibName:nil bundle:nil];
    [self presentViewController:m animated:YES completion:nil];

    //Also tried the depreciated presentModalViewController, same result
    //[self presentModalViewController:m animated:YES];
}

我正在使用Xcode 4.61。我已经编译成ipad 5.1,ipad 6.1和6.1上的真正的ipad 2。一切都相同。

2 个答案:

答案 0 :(得分:7)

试试..

@implementation KBViewController


    -(void)viewDidAppear:(BOOL)animated{

        KBModalViewController *m = [[KBModalViewController alloc] initWithNibName:nil bundle:nil];
        [m setModalPresentationStyle:UIModalPresentationFormSheet];
         [m setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
        [self presentViewController:m animated:YES completion:nil];

        //Also tried the depreciated presentModalViewController, same result
        //[self presentModalViewController:m animated:YES];
    }

答案 1 :(得分:1)

尝试这样 -

KBModalViewController *m = [[KBModalViewController alloc] initWithNibName:nil bundle:nil];
m.modalPresentationStyle = UIModalPresentationFormSheet;
m.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:m animated:YES];
[m release];