簡體   English   中英

呈現視圖控制器時出現黑屏

[英]Black screen when presenting view controller

我在情節提要板中繪制了一個300x350像素的視圖,我想在當前視圖(600x600像素,是初始視圖控制器)中顯示此視圖,為此,我嘗試以下代碼:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ModalViewController *viewController = (ModalViewController *)[storyboard instantiateViewControllerWithIdentifier:@"modalView"];

viewController.modalPresentationStyle = UIModalPresentationCurrentContext;
viewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

[self presentViewController:viewController animated:YES completion:^{
    viewController.view.superview.frame = CGRectMake(0, 0, 300, 350);
    viewController.view.superview.center = self.backgroundColorView.center;
}];

此代碼有兩個問題:

  1. 我的視圖在全屏模式下加載,並具有將屏幕尺寸更改為300x350像素的延遲。
  2. 在我的視圖之外,我可以看到黑屏(在我的情況下,該屏幕應該出現在其他視圖的一部分中)。

我怎么解決這個問題? (我沒有使用導航控制器)

您需要將modalPresentationStyle更改為overCurrentContex

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM