当前位置: 萬仟网 > IT编程>移动开发>IOS > iOS13中presentViewController的问题

iOS13中presentViewController的问题

2019年07月11日 14:31  | 萬仟网IT编程  | 我要评论

ios13中presentviewcontroller的问题

更新了xcode11.0 beta之后,在ios13中运行代码发现presentviewcontroller和之前弹出的样式不一样。

会出现这种情况是主要是因为我们之前对uiviewcontroller里面的一个属性,即modalpresentationstyle(该属性是控制器在模态视图时将要使用的样式)没有设置需要的类型。在ios13中modalpresentationstyle的默认改为uimodalpresentationautomatic,而在之前默认是uimodalpresentationfullscreen

/*
 defines the presentation style that will be used for this view controller when it is presented modally. set this property on the view controller to be presented, not the presenter.
 if this property has been set to uimodalpresentationautomatic, reading it will always return a concrete presentation style. by default uiviewcontroller resolves uimodalpresentationautomatic to uimodalpresentationpagesheet, but other system-provided view controllers may resolve uimodalpresentationautomatic to other concrete presentation styles.
 defaults to uimodalpresentationautomatic on ios starting in ios 13.0, and uimodalpresentationfullscreen on previous versions. defaults to uimodalpresentationfullscreen on all other platforms.
 */
@property(nonatomic,assign) uimodalpresentationstyle modalpresentationstyle api_available(ios(3.2));

要改会原来模态视图样式,我们只需要把uimodalpresentationstyle设置为uimodalpresentationfullscreen即可。

viewcontroller *vc = [[viewcontroller alloc] init];
vc.title = @"presentvc";
uinavigationcontroller *nav = [[uinavigationcontroller alloc] initwithrootviewcontroller:vc];
nav.modalpresentationstyle = uimodalpresentationfullscreen;
[self.window.rootviewcontroller presentviewcontroller:nav animated:yes completion:nil];

文章若有不对地方,欢迎批评指正

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

◎已有 0 人评论

Copyright © 2019  萬仟网 保留所有权利. 粤ICP备17035492号-1
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com