react-native-navigation的迁移库

RNNTabBarController.m 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #import "RNNTabBarController.h"
  2. @implementation RNNTabBarController {
  3. NSUInteger _currentTabIndex;
  4. }
  5. - (id<UITabBarControllerDelegate>)delegate {
  6. return self;
  7. }
  8. - (UIViewController *)getCurrentChild {
  9. return self.selectedViewController;
  10. }
  11. - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
  12. return self.selectedViewController.supportedInterfaceOrientations;
  13. }
  14. - (void)setSelectedIndexByComponentID:(NSString *)componentID {
  15. for (id child in self.childViewControllers) {
  16. UIViewController<RNNLayoutProtocol>* vc = child;
  17. if ([vc conformsToProtocol:@protocol(RNNLayoutProtocol)] && [vc.layoutInfo.componentId isEqualToString:componentID]) {
  18. [self setSelectedIndex:[self.childViewControllers indexOfObject:child]];
  19. }
  20. }
  21. }
  22. - (void)setSelectedIndex:(NSUInteger)selectedIndex {
  23. _currentTabIndex = selectedIndex;
  24. [super setSelectedIndex:selectedIndex];
  25. }
  26. - (UIStatusBarStyle)preferredStatusBarStyle {
  27. return self.selectedViewController.preferredStatusBarStyle;
  28. }
  29. #pragma mark UITabBarControllerDelegate
  30. - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
  31. [self.eventEmitter sendBottomTabSelected:@(tabBarController.selectedIndex) unselected:@(_currentTabIndex)];
  32. _currentTabIndex = tabBarController.selectedIndex;
  33. }
  34. @end