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

I am trying to open a new page when a user clicks the submit button in the app. However, this opens completely black screen with nothing on it. How do I make it open the viewController instead ?

4

5 回答 5

43

您没有输入用户界面的 nib 名称:

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];
于 2013-03-25T18:03:26.650 回答
9

迅速

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

不要忘记StoryBoard IdStoryBoard->中设置 ViewControlleridentity inspector

于 2015-05-14T22:10:08.067 回答
5

万一其他人发现这个,请确保您没有设置self.view.backgroundColor = UIColor.clearColor()要显示的视图......这为我解决了。

于 2016-02-19T18:47:03.573 回答
1

对于情节提要 iOS7

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
SuccessOrFailViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:@"SuccessOrFailViewController"];
[sfvc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:sfvc animated:YES completion:nil];
于 2014-08-13T20:25:14.947 回答
1

在故事板中添加和删除视图控制器并忘记使用最新的故事板标识符更新视图控制器后,我已经发生了这种情况。

例如,如果您以编程方式移动到新的视图控制器,如下所示(注意代码中的标识符是“FirstUserVC”):

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

确保在 Interface Builder 中设置 Storyboard ID,如下所示,FirstUserVC 在 Storyboard ID 的标识中列出: 在此处输入图像描述

于 2016-02-21T06:06:56.387 回答