In my App I use the call function to make a phone call! Apple rejected my app now, because I havenīt hidden or disabled the Call Button if a User has an Ipod Touch...
This is how I implemented the exact same thing.
Have a call button, but only if it's an iPhone
Code:
NSString *deviceType = [UIDevice currentDevice].localizedModel;
if ([deviceType isEqualToString:@"iPhone"]) {
//if it's an iPhone, great - add the button to the bar
}else {
//if you have something else you would like to put there instead....
}
I would say, do not add the button in IB. If you add it programmatically, you can just not add it if the device is not of the right type. Enabled and hidden don't work on bar buttons as far as I am aware.
Hi,
suppose you have a done button of UIBarButtonItem and u want to hide it and show it programmatically depends upon your requirement.so you have do like following...
To Hide:
Declaration
UIBarButtonItem *donebutton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemD one target:self action:@selector(ondoneButtonPressed)];
To Show:simply call
self.navigationItem.rightBarButtonItem = donebutton;
It will work for UIBarButtonItem , donebutton.hidden=YES will not work.
You can enable/disable by simply writing donebutton.enable=YES/NO.
Do not know about in which iphone environment for u r working but the given code will work for hiding and showing the UIBarButton for requirements in ur program.
swarnalata
Last edited by swarnalata; 06-15-2010 at 05:34 AM.