【发布时间】:2012-03-22 13:40:22
【问题描述】:
我有一个 rootViewController 和一个以编程方式创建的 UIButton。我希望这个 UIButton 显示另一个视图控制器。由于某种原因,它崩溃并出现以下错误:
架构 i386 的未定义符号:
“_OBJC_CLASS_$_TutorialViewController”,引用自: RootViewController.old 中的 objc-class-ref:未找到架构 i386 collect2 的符号:ld 返回 1 个退出状态
这是创建 Info UIButton 的代码。这段代码在 loadView 方法中:
// Create a Button to get Help
UIButton *helpButton = [UIButton buttonWithType:UIButtonTypeInfoDark ] ;
CGRect buttonRect = helpButton.frame;
// CALCulate the bottom right corner
buttonRect.origin.x = self.view.frame.size.width - buttonRect.size.width - 8;
buttonRect.origin.y = buttonRect.size.height - 8;
[helpButton setFrame:buttonRect];
[helpButton addTarget:self action:@selector(doHelp:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:helpButton];
}
这是转换到另一个视图控制器的操作:
- (IBAction)doHelp:(id)sender{
NSLog(@"help button pressed");
TutorialViewController *sampleView = [[[TutorialViewController alloc] init] autorelease];
[sampleView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:sampleView animated:YES];
}
感谢您的帮助。
【问题讨论】:
-
你为什么用“init”而不是“initWithNibName:bundle:”来初始化视图控制器?
-
init 应该没问题,最坏的情况是 viewController 没有视图并且显示为黑色。也许他从这个init方法调用
initWithNibName:bundle:。我不时这样做。 -
好的,所以这不是崩溃而是构建失败,对吧?事实上,这让我很困惑。
标签: iphone objective-c ios