I have a subView of the rootViewController and when called, buttons cannot be pressed on it without the error:
Thread 1: EXC_BAD_ACCESS
Here is the important code:
AppDelegate:
MainViewController *MainVC = [[MainViewController alloc]init] ;
self.window.rootViewController = mainVC ;
And in the MainViewController class:
OtherViewController *SomeView = [[OtherViewController alloc]init] ;
[self.view addSubview:SomeView.view] ;
The OtherViewController xib
loads as it should (the viewDidLoad
stuff executes). However, when I try to press one of the buttons in the simulator (on the OtherViewController
) I get the above error.
And the code of the button:
IBOutlet UIImageView *Image; //in OtherViewController.h
//in OtherViewController.m
- (IBAction)Button:(id)sender {
Image.center = CGPointMake(Image.center.x + 1, Image.center.y) ;
}
There are breakpoints throughout OtherViewController.h and .m (everywhere to do with the button). None are triggered. The program breaks and gives the error in AppDelegate: return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
Am I not setting up the second view properly so that it is fully-functional? How do I rid my program of this error?