欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

iOS13中presentViewController的问题

程序员文章站 2022-06-24 11:35:01
iOS13中presentViewController的问题 更新了Xcode11.0 beta之后,在iOS13中运行代码发现 和之前弹出的样式不一样。 会出现这种情况是主要是因为我们之前对 里面的一个属性,即 (该属性是控制器在模态视图时将要使用的样式)没有设置需要的类型。在iOS13中 的默认 ......

ios13中presentviewcontroller的问题

更新了xcode11.0 beta之后,在ios13中运行代码发现presentviewcontroller和之前弹出的样式不一样。
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];

iOS13中presentViewController的问题

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