I am trying to add a Right bar button in my tabbar's navigationbar
, and its working fine in iphone 5 and 5s device and all simulators. But its not showing up in iphone 6 and 6+ device.However its working fine on simulator of iphone 6 and 6+.
Here is the button code.
@property (nonatomic, weak) UIButton *rightButton;
-(void)setNavigationBarRightButton
{
rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
rightButton.frame = CGRectMake(0, 0, 40, 40);
rightButton.layer.cornerRadius = 20;
rightButton.layer.borderColor = [[UIColor lightGrayColor] CGColor];
rightButton.layer.borderWidth = 2;
rightButton.imageView.layer.cornerRadius = 20;
rightButton.clipsToBounds = YES;
UIImage* image;
NSData* imageData = [[NSUserDefaults standardUserDefaults] objectForKey:@"image"];
if (imageData == (id)[NSNull null] || imageData.length == 0) {
NSLog(@"image data is %@",imageData);
image = [UIImage imageNamed:@"defaultIcon.png"];
}
else {
image = [UIImage imageWithData:imageData];
}
// rightButton.imageView.image = image;
[rightButton setBackgroundImage:image forState:UIControlStateNormal];
[rightButton addTarget:self action:@selector(onClickrighttButton:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
self.tabBarController.navigationItem.rightBarButtonItem = rightBarButtonItem;
}
- (void)onClickrighttButton:(id)sender
{
NSLog(@"clicked");
}
You can see in the image as well
Also a clear image of iphone 6
See there is even no place holder appear as the button have a border of 2.
@property (nonatomic) UIButton *rightButton;
– Rolf