gpt4 book ai didi

iphone - UITabbar 的 "more" View 上的选定索引

转载 作者:行者123 更新时间:2023-12-03 18:44:43 25 4
gpt4 key购买 nike

如何管理 UITabBar 的“更多” View 上的用户选择?我有这段代码来管理 UITabBarItems 选择:

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {    
if (!(viewController == tabBarController.moreNavigationController)) {
int index = tabBarController.selectedIndex;
[[DataManager sharedInstance] setCurrentTabbarIndex:index];
}
}

它对于可见的 UITabBarItems 工作得很好,但是当用户从“更多” View 中选择某个项目时,我永远不会收到通知。有没有办法捕获“更多” View 的用户项目选择?谢谢!

最佳答案

UITabBarController 的“更多” View 与其他 View 分开处理。 Apple 关于此主题的讨论如下:

[The 'moreNavigationController'] property always contains a valid More navigation controller, even if a More button is not displayed on the screen. You can use the value of this property to select the More navigation controller in the tab bar interface or to compare it against the currently selected view controller.

Do not add the object stored in this property to your tab bar interface manually. The More controller is displayed automatically by the tab bar controller as it is needed. You must also not look for the More navigation controller in the array of view controllers stored in the viewControllers property. The tab bar controller does not include the More navigation controller in that array of objects.

据此判断,我认为你可以这样做:

int index = tabBarController.selectedIndex;
if (tabBarController.selectedViewController ==
tabBarController.moreNavigationController) {
index = -1; //assign some placeholder index for the "More" controller
}

关于iphone - UITabbar 的 "more" View 上的选定索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5366005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com