您当前的位置: 首页 >  ios

培根芝士

暂无认证

  • 3浏览

    0关注

    446博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

iOS13使用presentViewController的问题

培根芝士 发布时间:2019-10-09 11:37:15 ,浏览量:3

在iOS13中使用presentViewController的时候,页面顶部会空出一部分来。

原因是因为UIViewController的一个属性modalPresentationStyle

/*
 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 system-provided subclasses may resolve UIModalPresentationAutomatic to other concrete presentation styles. Participation in the resolution of UIModalPresentationAutomatic is reserved for system-provided view controllers.
 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));


typedef NS_ENUM(NSInteger, UIModalPresentationStyle) {
    UIModalPresentationFullScreen = 0,
    UIModalPresentationPageSheet API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos),
    UIModalPresentationFormSheet API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos),
    UIModalPresentationCurrentContext API_AVAILABLE(ios(3.2)),
    UIModalPresentationCustom API_AVAILABLE(ios(7.0)),
    UIModalPresentationOverFullScreen API_AVAILABLE(ios(8.0)),
    UIModalPresentationOverCurrentContext API_AVAILABLE(ios(8.0)),
    UIModalPresentationPopover API_AVAILABLE(ios(8.0)) API_UNAVAILABLE(tvos),
    UIModalPresentationBlurOverFullScreen API_AVAILABLE(tvos(11.0)) API_UNAVAILABLE(ios) API_UNAVAILABLE(watchos),
    UIModalPresentationNone API_AVAILABLE(ios(7.0)) = -1,
    UIModalPresentationAutomatic API_AVAILABLE(ios(13.0)) = -2,
};

在iOS13中,modalPresentationStyle的默认值是UIModalPresentationAutomatic,而在iOS12以下的版本,默认值是UIModalPresentationFullScreen,这就导致了在iOS13中present出来的页面没法全屏。

可以在presentViewController的时候设置controller为全屏样式。

ImageDisplayViewController *ctrl = [[ImageDisplayViewController alloc] init];
ctrl.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:ctrl animated:YES completion:nil];

 

关注
打赏
1660824269
查看更多评论
立即登录/注册

微信扫码登录

0.0382s