message: Handled a tab bar item being removed
  Only reset the selected index is too big for new number of tabs. Fire the onPress if changing index
diff: #import "NVTabBarItemView.h"
  @implementation NVSegmentedTabView
  -{
  - NSInteger _selectedIndex;
  -}
  - (id)init
  {
  - (void)setTitles:(NSArray<NSString *> *)titles
  {
  + NSInteger selectedIndex = MIN(MAX(0, self.selectedSegmentIndex), titles.count - 1);
  + BOOL selectedIndexChanged = selectedIndex != self.selectedSegmentIndex;
  [self removeAllSegments];
  for (NSString *title in titles) {
  [self insertSegmentWithTitle:title atIndex:self.numberOfSegments animated:NO];
  }
  - self.selectedSegmentIndex = _selectedIndex;
  + self.selectedSegmentIndex = selectedIndex;
  + if (!!self.window && selectedIndexChanged)
  + [self selectTab:YES];
  }
  - (void)setBackgroundColor:(UIColor *)backgroundColor
  - (void)didMoveToWindow
  {
  [super didMoveToWindow];
  + if (!!self.window)
  [self selectTab:NO];
  }
  - (void)tabPressed
  {
  - _selectedIndex = self.selectedSegmentIndex;
  [self selectTab:YES];
  }
  UIView* tabBar = [self.superview.subviews objectAtIndex:tabBarIndex];
  for(NSInteger i = 0; i < [tabBar.subviews count]; i++) {
  NVTabBarItemView *tabBarItem = (NVTabBarItemView *) [tabBar.subviews objectAtIndex:i];
  - tabBarItem.alpha = (i == _selectedIndex ? 1 : 0);
  - if (press && i == _selectedIndex && !!tabBarItem.onPress) {
  + tabBarItem.alpha = (i == self.selectedSegmentIndex ? 1 : 0);
  + if (press && i == self.selectedSegmentIndex && !!tabBarItem.onPress) {
  tabBarItem.onPress(nil);
  }
  }
  