presentViewController显示黑页面(presentViewController s

2019-07-23 07:32发布

- (IBAction)submitButtonClicked:(id)sender{
    NSLog(@"here");
    SuccessOrFailViewController *sfvc = [[SuccessOrFailViewController alloc] init];
    [self presentViewController:sfvc animated:NO completion:NULL];
}

我想,当用户点击应用中的提交按钮打开新的一页。 然而,这完全打开黑屏什么就可以了。 如何让打开的viewController呢?

Answer 1:

你是不是用户界面输入笔尖名称:

SuccessOrFailViewController *sfvc = [[SuccessOrFailViewController alloc] initWithNibName:@"SuccessOrFailViewController" bundle:nil];
[self presentViewController:sfvc animated:NO completion:NULL];

对于情节串连图板,这是要走的路:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
SuccessOrFailViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:@"SuccessOrFailViewController"];
[sfvc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:sfvc animated:YES];


Answer 2:

迅速

var next = self.storyboard?.instantiateViewControllerWithIdentifier("DashboardController") as! DashboardController
self.presentViewController(next, animated: true, completion: nil)

不要忘记设置的ViewController StoryBoard IdStoryBoard - > identity inspector



Answer 3:

柜面任何人发现这一点,请确保您没有设置self.view.backgroundColor = UIColor.clearColor()在视图中显示...这解决了这个问题对我来说。



Answer 4:

对于故事板iOS7

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
SuccessOrFailViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:@"SuccessOrFailViewController"];
[sfvc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:sfvc animated:YES completion:nil];


Answer 5:

我有这种情况发生添加和故事板删除视图控制器和遗忘了最新的故事板标识更新视图控制器之后。

例如,如果以编程方式移动到一个新的视图控制器,这样(代码音符标识符是“FirstUserVC”):

let firstLaunch = (storyboard?.instantiateViewControllerWithIdentifier("FirstUserVC"))! as UIViewController
self.navigationController?.pushViewController(firstLaunch, animated: true)

在Interface Builder中请确保您有故事板ID这样设置与FirstUserVC的身份为故事板ID列:



文章来源: presentViewController shows black page