I'm experimenting with the UITabBarControllerDelegate methods for the first time, but my app crashes ("Thread 1: Program received signal: "EXC_BAD_ACCESS") when a tab bar item is tapped.
Setup: Xcode 4.2.1, ARC, everything in storyboard, for iPhone, and I'm using the tab bar controller template.
A custom class, MyTabBarControllerDelegateClass, conforms to the UITabBarControllerDelegate protocol in order to handle messages from the tab bar controller.
I set the tab bar controller's delegate property in the following app delegate method:
Here's the implementation of my MyTabBarControllerDelegateClass class (yea, bad idea to include the word class in class names):
There's not much else going on in this app because it's just a practice app. Actually, I have barely touched the source code because I started from the tab bar template and I'm using storyboard. Anyway, when I run the app, it loads okay. Then I tap a tab bar item and BOOM, CRASH, SPLAT!
Thanks.
Setup: Xcode 4.2.1, ARC, everything in storyboard, for iPhone, and I'm using the tab bar controller template.
A custom class, MyTabBarControllerDelegateClass, conforms to the UITabBarControllerDelegate protocol in order to handle messages from the tab bar controller.
I set the tab bar controller's delegate property in the following app delegate method:
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UITabBarController *tabBarVC = (UITabBarController *)self.window.rootViewController;
MyTabBarControllerDelegateClass *delegate = [[MyTabBarControllerDelegateClass alloc] init];
tabBarVC.delegate = delegate;
return YES;
}
Code:
@implementation MyTabBarControllerDelegateClass
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
NSLog(@"tab bar item selected");
}
Thanks.
Last edited: