我一直在浏览关于此错误的无数帖子:
Undefined symbols for architecture i386:
"_OBJC_IVAR_$_UIViewController._view", referenced from:
-[ViewController viewDidLoad] in ViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我已经检查了.m文件和链接库并复制了捆绑文件。我正在使用xcode 4.6.2版本。我想以编程方式使ViewDidLoad中的Button。
最佳答案
确切原因尚不确定,但可能有许多原因导致此错误:
前任:
myButton = [[UIButton alloc] init];// Don't use like this
self.myButton = [[UIButton alloc] init];// Use like this
编辑:
用这个替换你的代码
self.button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
self.button.frame = CGRectMake(10, 220, 150, 30);
[self.button setTitle:@"Show" forState:UIControlStateNormal];
[self.button addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown];
[_view addSubview:self.button]; // Note if you have set property of _view then use it as self.view because it also may be the cause of error.
希望对您有帮助。
关于iphone - 从以下位置引用的体系结构i386 : "_OBJC_IVAR_$_UIViewController._view",的 undefined symbol :,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16296958/