iOS13中presentViewController的問題

iOS13中presentViewController的問題

更新了Xcode11.0 beta以後,在iOS13中運行代碼發現presentViewController和以前彈出的樣式不同。
ios

會出現這種狀況是主要是由於咱們以前對UIViewController裏面的一個屬性,即modalPresentationStyle(該屬性是控制器在模態視圖時將要使用的樣式)沒有設置須要的類型。在iOS13中modalPresentationStyle的默認改成UIModalPresentationAutomatic,而在以前默認是UIModalPresentationFullScreenide

/*
 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便可。this

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

文章如有不對地方,歡迎批評指正atom

相關文章
相關標籤/搜索