简体   繁体   English

呈现视图控制器时出现黑屏

[英]Black screen when presenting view controller

I have draw a view inside my storyboard that have 300x350 pixels, I want to present this view inside my current view (600x600 pixels and is a initial view controller), for this I try this code: 我在情节提要板中绘制了一个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;
}];

This code have two problems: 此代码有两个问题:

  1. My view load in full screen and have a delay that changes the screen size to 300x350 pixels. 我的视图在全屏模式下加载,并具有将屏幕尺寸更改为300x350像素的延迟。
  2. Outside of my view I can see a black screen (In my case was supposed to appear the part of my other view). 在我的视图之外,我可以看到黑屏(在我的情况下,该屏幕应该出现在其他视图的一部分中)。

How can I solve this problem? 我怎么解决这个问题? (I'm not using navigation controller) (我没有使用导航控制器)

您需要将modalPresentationStyle更改为overCurrentContex

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 以编程方式显示没有标识符的视图控制器会导致黑屏 - Presenting view controller without identifier programmatically results in black screen 从选项卡控制器在当前上下文中显示模型视图控制器后出现黑屏 - Black screen after presenting model view controller in current context from tab controller 从警报视图处理程序呈现新的视图控制器将显示黑屏 - Presenting new view controller from alert view handler displays black screen 移动到另一个屏幕时停止呈现呈现视图控制器 - Stop Present Presenting view controller when move to another screen 推视图控制器时出现黑屏 - Black screen when pushing view controller 尝试刷新视图控制器时出现黑屏 - Black Screen when trying to refresh view controller 从 UITabBarController 在当前上下文中呈现模态视图控制器后的黑屏 - Black screen after presenting modal view controller in current context from UITabBarController 当呈现另一个视图控制器时,如何阻止“ from”视图变黑? - How can I stop the “from” view from becoming black when presenting another view controller? 呈现视图控制器时的UIViewControllerHierarchyInconsistency - UIViewControllerHierarchyInconsistency when presenting view controller 呈现Modal View Controller登录屏幕 - Presenting Modal View Controller login screen
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM