没有父视图的当前视图控制器消失



我有一个UIViewController,它上面 - 我使用presentViewController来呈现一个新窗口:

controller.view.frame = source;
[self presentViewController:controller animated:NO completion:nil];

[UIView animateWithDuration:ANIMATION_NORMAL_DURATION animations:^{
    controller.view.frame = target;

}completion:^(BOOL finished) {

}];

当我这样做时 - 父控制器(自身)在新控制器(控制器)出现之前消失。它使它变得丑陋。

有没有更好的方法来实现它?(我不在那些ViewContollers中使用NavigationControler)

谢谢。

从iOS7开始,有modalPresentationStyle属性。将其设置为以下选项之一:UIModalPresentationOverFullScreen、UIModalPresentationOverCurrentContext、UIModalPresentationCustom

modalViewController.modalPresentationStyle = UIModalPresentationCustom;

不存在

,只需添加一个子视图

controller.view.frame = source;
//[self presentViewController:controller animated:NO completion:nil];
[self.view addSubview:controller.view];

[UIView animateWithDuration:ANIMATION_NORMAL_DURATION animations:^{
     controller.view.frame = target;
}completion:^(BOOL finished) {
}];

最新更新