![](/img/trans.png)
[英]Presenting view controller without identifier programmatically results in black screen
[英]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;
}];
此代碼有兩個問題:
我怎么解決這個問題? (我沒有使用導航控制器)
您需要將modalPresentationStyle更改為overCurrentContex
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.