当前位置: 移动技术网 > 移动技术>移动开发>IOS > iOS13中presentViewController的问题

iOS13中presentViewController的问题

2019年07月11日  | 移动技术网移动技术  | 我要评论

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];

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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网