iPhone how to enable or disable UITabBar

Posted by Dean Wagstaff on Stack Overflow See other posts from Stack Overflow or by Dean Wagstaff
Published on 2010-04-19T20:40:38Z Indexed on 2010/04/19 20:43 UTC
Read the original article Hit count: 1015

Filed under:
|

I have a simple app with a tab bar which based upon user input disables one or more of the bar items. I understand I need to use a UITabBarDelegate which I have tried to use. However when I call the delegate method I get an uncaught exception error [NSObject doesNotRecognizeSelector]. I am not sure I am doing this all right or that I haven't missed something. Any suggestions.

What I have now is the following:

WMViewController.h

import

define kHundreds 0

@interface WMViewController : UIViewController {

}

@end

WMViewController.m

import "WMViewController.h"

import "MLDTabBarControllerAppDelegate.h"

@implementation WMViewController

  • (IBAction)finishWizard{ MLDTabBarControllerAppDelegate *appDelegate = (MLDTabBarControllerAppDelegate *)[[UIApplication sharedApplication] delegate]; [appDelegate setAvailabilityTabIndex:0 Enable:TRUE];

}

MLDTabBarControllerAppDelegate.h

import

@interface MLDTabBarControllerAppDelegate : NSObject {

}

  • (void) setAvailabilityTabIndex: (NSInteger) index Enable: (BOOL) enable;

@end

MLDTabBarControllerAppDelegate.m

import "MLDTabBarControllerApplicationDelegate.h"

import "MyListDietAppDelegate.h"

@implementation MLDTabBarControllerAppDelegate

  • (void) setAvailabilityTabIndex: (NSInteger) index Enable: (BOOL) enable { UITabBarController *controller = (UITabBarController *)[[[MyOrganizerAppDelegate getTabBarController] viewControllers ] objectAtIndex:index];

[[controller tabBarItem] setEnabled:enable]; }

@end

I get what appear to be a good controller object but crash on the [[controller tabBarItem]setEnabled:enable];

What am I missing...

Any suggestions

Thanks,

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uitabbar