Skip to content

Commit 4691509

Browse files
committed
v1.23.1 update popSelect API to support issue #286
1 parent f80aade commit 4691509

7 files changed

+21
-21
lines changed

CYLTabBarController.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "CYLTabBarController"
3-
s.version = "1.23.0"
3+
s.version = "1.23.1"
44
s.summary = "Highly customizable tabBar and tabBarController for iOS"
55
s.description = "CYLTabBarController is iPad and iPhone compatible. Supports landscape and portrait orientations and can be used inside UINavigationController."
66
s.homepage = "https://github.com/ChenYilong/CYLTabBarController"

CYLTabBarController/CYLPlusButton.m

+1-3
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ - (void)plusChildViewControllerButtonClicked:(UIButton<CYLPlusButtonSubclassing>
6666
}
6767
CYLTabBarController *tabBarController = [sender cyl_tabBarController];
6868
NSInteger index = [tabBarController.viewControllers indexOfObject:CYLPlusChildViewController];
69-
@try {
69+
if (NSNotFound != index && (index < tabBarController.viewControllers.count)) {
7070
[tabBarController setSelectedIndex:index];
71-
} @catch (NSException *exception) {
72-
NSLog(@"🔴类名与方法名:%@(在第%@行),描述:%@", @(__PRETTY_FUNCTION__), @(__LINE__), exception);
7371
}
7472
}
7573

CYLTabBarController/CYLTabBar+CYLTabBarControllerExtention.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@ NS_ASSUME_NONNULL_BEGIN
1616
- (NSArray<UIControl *> *)cyl_visibleControls;
1717
- (NSArray<UIControl *> *)cyl_subTabBarButtons;
1818
- (NSArray<UIControl *> *)cyl_subTabBarButtonsWithoutPlusButton;
19-
- (UIControl *)cyl_visibleControlWithIndex:(NSUInteger)index;
20-
//- (UIControl *)cyl_subTabBarButtonWithIndex:(NSUInteger)index;
21-
//- (void)cyl_animationLottieImageWithSelectedIndex:(NSUInteger)selectedIndex;
22-
//- (void)cyl_animationLottieImageWithSelectedControl:(UIControl *)selectedControl;
19+
- (UIControl *)cyl_tabBarButtonWithTabIndex:(NSUInteger)tabIndex;
2320
- (void)cyl_animationLottieImageWithSelectedControl:(UIControl *)selectedControl
2421
lottieURL:(NSURL *)lottieURL
2522
size:(CGSize)size;
2623
- (void)cyl_stopAnimationOfAllLottieView;
2724
- (NSArray *)cyl_originalTabBarButtons;
28-
//- (NSArray *)cyl_tabBarButtonFromTabBarSubviews:(NSArray *)tabBarSubviews;
29-
//- (NSArray *)cyl_sortedSubviews;
3025
- (BOOL)cyl_hasPlusChildViewController;
3126

3227
@end

CYLTabBarController/CYLTabBar+CYLTabBarControllerExtention.m

+13-8
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ - (NSArray *)cyl_tabBarButtonFromTabBarSubviews:(NSArray *)tabBarSubviews {
7676

7777
- (NSArray *)cyl_visibleControls {
7878
NSMutableArray *originalTabBarButtons = [NSMutableArray arrayWithArray:[self.cyl_originalTabBarButtons copy]];
79-
if (CYLExternPlusButton) {
79+
BOOL notAdded = (NSNotFound == [originalTabBarButtons indexOfObject:CYLExternPlusButton]);
80+
if (CYLExternPlusButton && notAdded) {
8081
[originalTabBarButtons addObject:CYLExternPlusButton];
8182
}
8283
if (originalTabBarButtons.count == 0) {
@@ -126,13 +127,17 @@ - (NSArray *)cyl_visibleControls {
126127
return subControls;
127128
}
128129

129-
- (UIControl *)cyl_subTabBarButtonWithIndex:(NSUInteger)index {
130-
UIControl *selectedControl;
131-
@try {
132-
NSArray *subControls = self.cyl_subTabBarButtons;
133-
selectedControl = subControls[index];
134-
} @catch (NSException *exception) {
135-
NSLog(@"🔴类名与方法名:%@(在第%@行),描述:%@", @(__PRETTY_FUNCTION__), @(__LINE__), exception.reason);
130+
- (UIControl *)cyl_tabBarButtonWithTabIndex:(NSUInteger)tabIndex {
131+
UIControl *selectedControl = [self cyl_visibleControlWithIndex:tabIndex];
132+
NSInteger plusViewControllerIndex = [self.cyl_tabBarController.viewControllers indexOfObject:CYLPlusChildViewController];
133+
BOOL isPlusButton = selectedControl.cyl_isPlusButton;
134+
BOOL shouldSelect = (plusViewControllerIndex <= self.cyl_tabBarController.viewControllers.count) && isPlusButton;
135+
if (!shouldSelect) {
136+
@try {
137+
selectedControl = [self cyl_subTabBarButtonsWithoutPlusButton][tabIndex];
138+
} @catch (NSException *exception) {
139+
NSLog(@"🔴类名与方法名:%@(在第%@行),描述:%@", @(__PRETTY_FUNCTION__), @(__LINE__), exception.reason);
140+
}
136141
}
137142
return selectedControl;
138143
}

CYLTabBarController/CYLTabBarController.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ - (void)viewDidLoad {
6464
- (void)setSelectedIndex:(NSUInteger)selectedIndex {
6565
[super setSelectedIndex:selectedIndex];
6666
[self updateSelectionStatusIfNeededForTabBarController:nil shouldSelectViewController:nil];
67-
UIControl *selectedControl = [self.tabBar cyl_visibleControlWithIndex:selectedIndex];
67+
UIControl *selectedControl = [self.tabBar cyl_tabBarButtonWithTabIndex:selectedIndex];
6868
if (selectedControl) {
6969
[self didSelectControl:selectedControl];
7070
}

Example/Classes/Module/SameCity/CYLDetailsViewController.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ - (void)viewDidLoad {
3131
}
3232

3333
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
34-
[self cyl_popSelectTabBarChildViewControllerAtIndex:3 completion:^(__kindof UIViewController *selectedTabBarChildViewController) {
34+
// [self cyl_popSelectTabBarChildViewControllerAtIndex:3 completion:^(__kindof UIViewController *selectedTabBarChildViewController) {
35+
[self cyl_popSelectTabBarChildViewControllerForClassType:[CYLMineViewController class] completion:^(__kindof UIViewController *selectedTabBarChildViewController) {
3536
CYLMineViewController *mineViewController = selectedTabBarChildViewController;
3637
@try {
3738
[mineViewController testPush];

Podfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ source 'git@github.com:CocoaPods/Specs.git'
66
target 'CYLTabBarController' do
77
# Comment the next line if you don't want to use dynamic frameworks
88
use_frameworks!
9-
9+
#pod 'lottie-ios', '~> 2.5.0'
1010
pod 'CYLTabBarController', :path => './'
11+
#pod 'CYLTabBarController', '~> 1.23.1'
1112

1213
end

0 commit comments

Comments
 (0)