I need your help here. My app has 5 tab bars. The first tab bar's image will be missing after make a phone call using openURL. And this is only happen when running the app in iOS 8/9.
Below is the coding where I make a phone call:
-(void)callDistributor
{
NSString *phoneNo= [@"tel://" stringByAppendingString:phoneNumber_];
phoneNo = [phoneNo stringByReplacingOccurrencesOfString:@" " withString:@""];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNo]];
}
Below is the coding (in delegate.m) where the tab bars are created:
- (void)addCustomTabbar {
NSArray *array =
[NSArray arrayWithObjects:@"products",
@"fav",
@"buy",
@"about",
@"settings", nil];
UIImage *buttonImage, *buttonImageSelected;
for (int i = 0; i < [array count]; i++) {
NSString *active =
[NSString stringWithFormat:@"%@_active.png", [array objectAtIndex:i]];
NSString *inActive =
[NSString stringWithFormat:@"%@.png", [array objectAtIndex:i]];
buttonImage = [UIImage imageNamed:inActive];
buttonImageSelected = [UIImage imageNamed:active];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.tag = i;
button.autoresizingMask = (UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleBottomMargin |
UIViewAutoresizingFlexibleTopMargin);
CGFloat heightDifference =
buttonImage.size.height -
tabBarController_.tabBar.frame.size.height;
button.frame = CGRectMake(i * buttonImage.size.width,
tabBarController_.view.frame.size.height -
tabBarController_.tabBar.frame.size.height - 1 - heightDifference,
buttonImage.size.width,
buttonImage.size.height);
[button setBackgroundImage:buttonImage forState:UIControlStateNormal];
[button setBackgroundImage:buttonImageSelected
forState:UIControlStateSelected];
[button addTarget:self
action:@selector(changeTabbar:)
forControlEvents:UIControlEventTouchDown];
[button setSelected:(i == 0)];
[tabBarController_.view addSubview:button];
}
addedTabBar_ = YES;
}
- (void)changeTabbar:(id)sender {
int tagNum = [sender tag];
tabBarController_.selectedIndex = tagNum;
for (UIView *view in tabBarController_.view.subviews) {
if ([view isKindOfClass:[UIButton class]]) {
UIButton *button = (UIButton *)view;
[button setSelected:(tagNum == button.tag)];
}
}
}
Only the first tab bar will missing after phone call, the other 4 tab bars are working fine. Any ideas? Thanks in advance.