Skip to content

Commit ca27416

Browse files
benoitvallonfacebook-github-bot
authored andcommitted
Fix badgeColor for previous iOS 10 versions
Summary: The actual badgeColor prop causes the following error when run on device with a version inferior to iOS 10 like iPad 2 and iPad mini 1. `*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITabBarItem setBadgeColor:]: unrecognized selector sent to instance 0x7968be80'` This PR fixes it by checking at runtime if the selector is available for the current running version. It also makes the color available at start by using the variable `self.barItem`. Currently, the color appears only after a reload. Closes facebook#12354 Differential Revision: D4598036 Pulled By: shergin fbshipit-source-id: 9f104fc27db51213a54273e33c5a22f1b350c55e
1 parent 13edf6d commit ca27416

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

React/Views/RCTTabBarItem.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,10 @@ - (void)setSelectedIcon:(UIImage *)selectedIcon
107107

108108
- (void)setBadgeColor:(UIColor *)badgeColor
109109
{
110-
#if !TARGET_OS_TV && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
111-
_barItem.badgeColor = badgeColor;
112-
#endif
110+
// badgeColor available since iOS 10
111+
if ([self.barItem respondsToSelector:@selector(badgeColor)]) {
112+
self.barItem.badgeColor = badgeColor;
113+
}
113114
}
114115

115116
- (UIViewController *)reactViewController

0 commit comments

Comments
 (0)