12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #import "RNNTabBarController.h"
-
- @implementation RNNTabBarController {
- NSUInteger _currentTabIndex;
- }
-
- - (id<UITabBarControllerDelegate>)delegate {
- return self;
- }
-
- - (UIViewController *)getCurrentChild {
- return self.selectedViewController;
- }
-
- - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
- return self.selectedViewController.supportedInterfaceOrientations;
- }
-
- - (void)setSelectedIndexByComponentID:(NSString *)componentID {
- for (id child in self.childViewControllers) {
- UIViewController<RNNLayoutProtocol>* vc = child;
-
- if ([vc conformsToProtocol:@protocol(RNNLayoutProtocol)] && [vc.layoutInfo.componentId isEqualToString:componentID]) {
- [self setSelectedIndex:[self.childViewControllers indexOfObject:child]];
- }
- }
- }
-
- - (void)setSelectedIndex:(NSUInteger)selectedIndex {
- _currentTabIndex = selectedIndex;
- [super setSelectedIndex:selectedIndex];
- }
-
- - (UIStatusBarStyle)preferredStatusBarStyle {
- return self.selectedViewController.preferredStatusBarStyle;
- }
-
- #pragma mark UITabBarControllerDelegate
-
- - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
- [self.eventEmitter sendBottomTabSelected:@(tabBarController.selectedIndex) unselected:@(_currentTabIndex)];
- _currentTabIndex = tabBarController.selectedIndex;
- }
-
- @end
|