I've been looking through countless posts about this error:
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)
I already checked .m file and link libraries and copy bundle file. i am using xcode 4.6.2 version. i want to make programmatically Button in ViewDidLoad.
There is uncertainty for the exact reason but there may be many reasons for this error:
Either the button isn't instantiated (allocated & initialized) i.e. button is nil.
If you have made button globally then access it using self
Ex:
myButton = [[UIButton alloc] init];// Don't use like this
self.myButton = [[UIButton alloc] init];// Use like this
EDIT : replace your code with 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.
Hope it helps you.
are you referencing self.view by using _view notation? that could be the problem. try switching out _view for self.view
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With