加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iphone – 当modalPresentationStyle设置为UIModalPresentationC

发布时间:2020-12-14 20:05:03 所属栏目:百科 来源:网络整理
导读:当我将UIVavController的UIVavContController设置为UIModalPresentationCurrentContext时,UIViewController的UIViewController不会滑入.没有使用转换. 这是我的代码: UIViewController *viewController = [[UIViewController alloc] init];UINavigationCont
当我将UIVavController的UIVavContController设置为UIModalPresentationCurrentContext时,UIViewController的UIViewController不会滑入.没有使用转换.

这是我的代码:

UIViewController *viewController = [[UIViewController alloc] init];

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
navController.navigationBarHidden = YES;

self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;

[self presentViewController:navController animated:YES completion:nil];

当我没有设置modalPresenttionStyle时,一切正常.但是我需要这种风格,因为我希望UIViewController呈现为叠加.

BTW:当ViewController被关闭时,动画效果很好.

解决方法

根据UIViewController.h头文件定义:

/ *
??定义当视图控制器以模态显示时将用于该视图控制器的转换样式.组
??该属性在视图控制器上呈现,而不是演示者.默认为
??UIModalTransitionStyleCoverVertical.
* /

所以你应该在presentationViewController上应用这样:

UIViewController *viewController = [[UIViewController alloc] init];

 UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
 navController.navigationBarHidden = YES;

//Here is the change
 navController.modalPresentationStyle = UIModalPresentationCurrentContext;

[self presentViewController:navController animated:YES completion:nil];

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读