Skip to content

Commit

Permalink
v1.23.1 update popSelect API to support issue #286
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenYilong committed Apr 19, 2019
1 parent f80aade commit 4691509
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CYLTabBarController.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "CYLTabBarController"
s.version = "1.23.0"
s.version = "1.23.1"
s.summary = "Highly customizable tabBar and tabBarController for iOS"
s.description = "CYLTabBarController is iPad and iPhone compatible. Supports landscape and portrait orientations and can be used inside UINavigationController."
s.homepage = "https://github.com/ChenYilong/CYLTabBarController"
Expand Down
4 changes: 1 addition & 3 deletions CYLTabBarController/CYLPlusButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ - (void)plusChildViewControllerButtonClicked:(UIButton<CYLPlusButtonSubclassing>
}
CYLTabBarController *tabBarController = [sender cyl_tabBarController];
NSInteger index = [tabBarController.viewControllers indexOfObject:CYLPlusChildViewController];
@try {
if (NSNotFound != index && (index < tabBarController.viewControllers.count)) {
[tabBarController setSelectedIndex:index];
} @catch (NSException *exception) {
NSLog(@"🔴类名与方法名:%@(在第%@行),描述:%@", @(__PRETTY_FUNCTION__), @(__LINE__), exception);
}
}

Expand Down
7 changes: 1 addition & 6 deletions CYLTabBarController/CYLTabBar+CYLTabBarControllerExtention.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,12 @@ NS_ASSUME_NONNULL_BEGIN
- (NSArray<UIControl *> *)cyl_visibleControls;
- (NSArray<UIControl *> *)cyl_subTabBarButtons;
- (NSArray<UIControl *> *)cyl_subTabBarButtonsWithoutPlusButton;
- (UIControl *)cyl_visibleControlWithIndex:(NSUInteger)index;
//- (UIControl *)cyl_subTabBarButtonWithIndex:(NSUInteger)index;
//- (void)cyl_animationLottieImageWithSelectedIndex:(NSUInteger)selectedIndex;
//- (void)cyl_animationLottieImageWithSelectedControl:(UIControl *)selectedControl;
- (UIControl *)cyl_tabBarButtonWithTabIndex:(NSUInteger)tabIndex;
- (void)cyl_animationLottieImageWithSelectedControl:(UIControl *)selectedControl
lottieURL:(NSURL *)lottieURL
size:(CGSize)size;
- (void)cyl_stopAnimationOfAllLottieView;
- (NSArray *)cyl_originalTabBarButtons;
//- (NSArray *)cyl_tabBarButtonFromTabBarSubviews:(NSArray *)tabBarSubviews;
//- (NSArray *)cyl_sortedSubviews;
- (BOOL)cyl_hasPlusChildViewController;

@end
Expand Down
21 changes: 13 additions & 8 deletions CYLTabBarController/CYLTabBar+CYLTabBarControllerExtention.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ - (NSArray *)cyl_tabBarButtonFromTabBarSubviews:(NSArray *)tabBarSubviews {

- (NSArray *)cyl_visibleControls {
NSMutableArray *originalTabBarButtons = [NSMutableArray arrayWithArray:[self.cyl_originalTabBarButtons copy]];
if (CYLExternPlusButton) {
BOOL notAdded = (NSNotFound == [originalTabBarButtons indexOfObject:CYLExternPlusButton]);
if (CYLExternPlusButton && notAdded) {
[originalTabBarButtons addObject:CYLExternPlusButton];
}
if (originalTabBarButtons.count == 0) {
Expand Down Expand Up @@ -126,13 +127,17 @@ - (NSArray *)cyl_visibleControls {
return subControls;
}

- (UIControl *)cyl_subTabBarButtonWithIndex:(NSUInteger)index {
UIControl *selectedControl;
@try {
NSArray *subControls = self.cyl_subTabBarButtons;
selectedControl = subControls[index];
} @catch (NSException *exception) {
NSLog(@"🔴类名与方法名:%@(在第%@行),描述:%@", @(__PRETTY_FUNCTION__), @(__LINE__), exception.reason);
- (UIControl *)cyl_tabBarButtonWithTabIndex:(NSUInteger)tabIndex {
UIControl *selectedControl = [self cyl_visibleControlWithIndex:tabIndex];
NSInteger plusViewControllerIndex = [self.cyl_tabBarController.viewControllers indexOfObject:CYLPlusChildViewController];
BOOL isPlusButton = selectedControl.cyl_isPlusButton;
BOOL shouldSelect = (plusViewControllerIndex <= self.cyl_tabBarController.viewControllers.count) && isPlusButton;
if (!shouldSelect) {
@try {
selectedControl = [self cyl_subTabBarButtonsWithoutPlusButton][tabIndex];
} @catch (NSException *exception) {
NSLog(@"🔴类名与方法名:%@(在第%@行),描述:%@", @(__PRETTY_FUNCTION__), @(__LINE__), exception.reason);
}
}
return selectedControl;
}
Expand Down
2 changes: 1 addition & 1 deletion CYLTabBarController/CYLTabBarController.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ - (void)viewDidLoad {
- (void)setSelectedIndex:(NSUInteger)selectedIndex {
[super setSelectedIndex:selectedIndex];
[self updateSelectionStatusIfNeededForTabBarController:nil shouldSelectViewController:nil];
UIControl *selectedControl = [self.tabBar cyl_visibleControlWithIndex:selectedIndex];
UIControl *selectedControl = [self.tabBar cyl_tabBarButtonWithTabIndex:selectedIndex];
if (selectedControl) {
[self didSelectControl:selectedControl];
}
Expand Down
3 changes: 2 additions & 1 deletion Example/Classes/Module/SameCity/CYLDetailsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ - (void)viewDidLoad {
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self cyl_popSelectTabBarChildViewControllerAtIndex:3 completion:^(__kindof UIViewController *selectedTabBarChildViewController) {
// [self cyl_popSelectTabBarChildViewControllerAtIndex:3 completion:^(__kindof UIViewController *selectedTabBarChildViewController) {
[self cyl_popSelectTabBarChildViewControllerForClassType:[CYLMineViewController class] completion:^(__kindof UIViewController *selectedTabBarChildViewController) {
CYLMineViewController *mineViewController = selectedTabBarChildViewController;
@try {
[mineViewController testPush];
Expand Down
3 changes: 2 additions & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ source 'git@github.com:CocoaPods/Specs.git'
target 'CYLTabBarController' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

#pod 'lottie-ios', '~> 2.5.0'
pod 'CYLTabBarController', :path => './'
#pod 'CYLTabBarController', '~> 1.23.1'

end

0 comments on commit 4691509

Please sign in to comment.