Hello guys! I have an issue that is puzzling me. I've created a category for UITabBarItem and it looks like this:
And here is my implementation in my ViewController subclass:
The intention of this is to customize the images displayed in the UITabBarController because the blue chrome color don't fit inside my design. It works like a champ in the Simulator however, when I try to run this in my iPhone device using the "Device|Debug" method, I get the following compilation error:
Could this be an Xcode bug? Am I doing something wrong?
Conceptually, I should be able to access these private variables because I'm extending UITabBarItem.
The other option will be to subclass the UITabBarItem and use it's drawRect method, however I don't know how to init the object because it's managed by a ViewController.
Any tips and suggestions will be highly appreciated.
-ML
Code:
@implementation UITabBarItem (UITabBarItemCategory)
-(void)setImage:(UIImage*)image{
if(image == NULL){ //might be called with NULL argument
return;
}
_image = [image retain];
_selectedImage = [image retain];
}
@end
And here is my implementation in my ViewController subclass:
Code:
#import "MainScreenViewController.h"
#import "UITabBarItemCategory.h"
@implementation MainScreenViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Initialization code
self.title = NSLocalizedString(@"main_tab_title","Main screen tab button");
[self.tabBarItem setImage:[UIImage imageNamed:@"TabBarItemMain.png"]];
}
return self;
}
The intention of this is to customize the images displayed in the UITabBarController because the blue chrome color don't fit inside my design. It works like a champ in the Simulator however, when I try to run this in my iPhone device using the "Device|Debug" method, I get the following compilation error:
Code:
"_OBJC_IVAR_$_UITabBarItem._image", referenced from:
_OBJC_IVAR_$_UITabBarItem._image$non_lazy_ptr in UICategory.o
"_OBJC_IVAR_$_UITabBarItem._selectedImage", referenced from:
_OBJC_IVAR_$_UITabBarItem._selectedImage$non_lazy_ptr in UICategory.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Build failed (2 errors)
Could this be an Xcode bug? Am I doing something wrong?
Conceptually, I should be able to access these private variables because I'm extending UITabBarItem.
The other option will be to subclass the UITabBarItem and use it's drawRect method, however I don't know how to init the object because it's managed by a ViewController.
Any tips and suggestions will be highly appreciated.
-ML