【发布时间】:2012-08-17 09:15:35
【问题描述】:
我有一个 Storyboard View Controller(带有我自己的自定义子类),其中我有一个 initWithCoder 自定义方法,我想在其中使用我自己的自定义对象来流行视图(我想保持以编程方式执行此操作的灵活性。
代码在调用 [self.view addSubview:button]; 之前运行良好,然后崩溃并显示:“无法在包中加载 NIB”。
我只想在视图上添加一个 UIButton...
- (id)initWithCoder:(NSCoder*)aDecoder
{
if(self = [super initWithCoder:aDecoder])
{
[self initLoginForm];
}
return self;
}
-(void)initLoginForm
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(100, 170, 100, 30);
[button setTitle:@"Login..." forState:UIControlStateNormal];
[button addTarget:self action:@selector(handleLoginAttempt) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}
【问题讨论】:
标签: iphone ios ios4 storyboard