chwFinishedViewController

chwFinishedViewController

当我调用视图控制器时,它变成空白,似乎不能正确调用我的NIB中的布局。我还有至少5个其他类很好地尊重我的NIB布局。

我有一个chwFinishedViewController.h

在我的情节提要上,我有一个UIViewController,分配了该类并指定了storyboardID complete。见下面的截图



这是chwFinishedViewController.m

#import "chwFinishedViewController.h"

@interface chwFinishedViewController ()

@end

@implementation chwFinishedViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

这就是我所说的控制器。控制器调用之前的所有操作都会正确执行:
 if (!error) {
chwFinishedViewController *complete = [[chwFinishedViewController alloc] init];
[self.navigationController pushViewController:complete animated:YES];

}

最佳答案

试试这个:

chwFinishedViewController *complete = [[chwFinishedViewController alloc] initWithNibName:@"complete" bundle:nil];

xib和chwFinishedViewController构造函数之间没有关系。您只使用init并不会产生任何效果。 Here's apple doc

编辑

您使用情节提要。所以试试这个:
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
chwFinishedViewController* complete = [storyboard instantiateViewControllerWithIdentifier:@"complete"];

07-26 09:38