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.
1) If you are using Autoresizing Sub-Mask check Whether you have set the 'Autoresizing Mask' properly, [Check in Preview].
2) If you are using Size class then make sure about the constraints you have set, [Check in Preview].
3) Second thing if its not working by any way and you are in hurry, Simply use your custom header view instead of navigation bar with custom buttons on right and left.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With