gpt4 book ai didi

iOS:从标签栏调用操作表

转载 作者:行者123 更新时间:2023-11-29 12:38:10 26 4
gpt4 key购买 nike

我已经在 Stackoverflow 上查看了该主题的所有其他答案,但没有真正深入。我已经在 Storyboard 中设置了我的 Tabbar Controller 。我也在 Storyboard 中定义了标签栏项目的图标,但是我已经通过代码在它们各自的 View Controller 中设置了标题,因为我的应用程序提供了多语言支持。

现在我想要一个单独的标签栏按钮,它不会跳转到另一个 View ,而只是调用一个操作表。无论我在哪个其他标签栏上。所以我的问题是:

  1. 我在哪里添加这个标签栏按钮?因为所有其他按钮我只能在创建到新 View Controller 的 segue 之后定义
  2. 我应该在哪里放置操作表的代码?!

最佳答案

我不太了解标签栏,但我会执行以下操作:假设您正在使用 TabBarController View 或带有 TabBar 的中央 View 。

在-viewDidLoad

NSMutableArray *tmp = [[NSMutableArray alloc] initWithArray:self.tabBarController.viewControllers];

UIViewController *sheet= [[UIViewContoller alloc] init];
sheet.title = @"Sheet";
sheet.tabBarItem.image = [UIImage....];

[tmp addObject:sheet];

[self.tabBarController setviewControllers:tmp];

self.tabBarController.delegate = self;

然后放置以下内容

-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
if([viewController.Title isEqualToString:@"Sheet"])
{
//ActionSheet create code here
retrun NO;
}
else
{
return YES;
}
}

关于iOS:从标签栏调用操作表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25703732/

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