I added a subview to my main view, the subview has a button on it, but when I select the button on the subview, the application crashes with the following highlited in green:
Thread 1:EXC_BAD_ACCESS (code=1), address=0xf0000008
The subview has its own viewcontroller and xib file.
heres some of the code I used:
Subview.h
- (IBAction)setDummyTime:(id)sender;
Main view.m
PickupTimeViewController *pickupTimeView = [[PickupTimeViewController alloc]init];
[selectedView addSubview:pickupTimeView.view];
Thanks
Sounds like its been dealloc'ed on you.
Try turning on Zombie mode, crash the app again and see if it points you to whats going on, it will tell which object is trying to do something after being released.
Xcode -> Click your scheme -> Edit Scheme -> Run -> Diagnostics -> Tick Enable Zombie Objects
Another thing to try is to watch your subView in the debug area, this will tell you when your subView is released.
Example of setting watch
Also if you have not already tried it, try keep a strong/retain reference to your subview.
If you can't get it working post the code you create the view with.
EDIT: in .h
@property (nonatomic, strong) PickupTimeViewController *pickupTimeView;
in .m
self.pickupTimeView = [[PickupTimeViewController alloc]init];
[selectedView addChildViewController:self.pickupTimeView]; // (i0S5+ only) if the view you add to is a view controller if not use self otherwise.
[selectedView addSubview:pickupTimeView.view];
Good luck, BooRanger
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