We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
初始化CYLTabBarController时,使用:@{ CYLTabBarItemTitle : title ?: @"", CYLTabBarItemImage : img ?: @"", CYLTabBarItemSelectedImage : selectedImg ?: @"", }方式设置过一次。由于业务需要,在某些时机使用: [[[self.tabBar].items objectAtIndex:index] setImage:img]; [[[sel.tabBar].items objectAtIndex:index] setSelectedImage:selectedImg];方式重新设置一次。导致[bug]:- (void)tabBarController:(UITabBarController *)tabBarController didSelectControl:(UIControl *)control不回调。
排查发现调用[[[self.tabBar].items objectAtIndex:index] setImage:img]; [[[sel.tabBar].items objectAtIndex:index] setSelectedImage:selectedImg];再调用[self.view setNeedsLayout];重新触发CYLTabBarController的viewDidLayoutSubviews方法,即重新走到 CYLTabBar *tabBar = (CYLTabBar *)self.tabBar; // add callback for visiable control, included all plusButton. [tabBar.cyl_visibleControls enumerateObjectsUsingBlock:^(UIControl * _Nonnull control, NSUInteger idx, BOOL * _Nonnull stop) { //to avoid invoking didSelectControl twice, because plusChildViewControllerButtonClicked will invoke setSelectedIndex if ([control cyl_isChildViewControllerPlusButton]) { return; } SEL actin = @selector(didSelectControl:); [control addTarget:self action:actin forControlEvents:UIControlEventTouchUpInside]; if (idx == self.selectedIndex) { control.selected = YES; } }];逻辑,能解决[bug]:- (void)tabBarController:(UITabBarController *)tabBarController didSelectControl:(UIControl *)control不回调的问题。求问原因?
The text was updated successfully, but these errors were encountered:
ChenYilong
No branches or pull requests
Base Info for this issue
1. How to reproduce the problem.
2. Please help me in this way.
排查发现调用[[[self.tabBar].items objectAtIndex:index] setImage:img];
[[[sel.tabBar].items objectAtIndex:index] setSelectedImage:selectedImg];再调用[self.view setNeedsLayout];重新触发CYLTabBarController的viewDidLayoutSubviews方法,即重新走到 CYLTabBar *tabBar = (CYLTabBar *)self.tabBar;
// add callback for visiable control, included all plusButton.
[tabBar.cyl_visibleControls enumerateObjectsUsingBlock:^(UIControl * _Nonnull control, NSUInteger idx, BOOL * _Nonnull stop) {
//to avoid invoking didSelectControl twice, because plusChildViewControllerButtonClicked will invoke setSelectedIndex
if ([control cyl_isChildViewControllerPlusButton]) {
return;
}
SEL actin = @selector(didSelectControl:);
[control addTarget:self action:actin forControlEvents:UIControlEventTouchUpInside];
if (idx == self.selectedIndex) {
control.selected = YES;
}
}];逻辑,能解决[bug]:- (void)tabBarController:(UITabBarController *)tabBarController didSelectControl:(UIControl *)control不回调的问题。求问原因?
3. Here is a Demo.
4. Here is my Debug log
The text was updated successfully, but these errors were encountered: