Objective-C 如何从与当前视图重叠的选项卡栏显示操作 sheet?

Objective-C how to present an action sheet from tab bar that overlaps the current view?

我想添加一个操作 sheet,该操作会在单击标签栏中心项目时出现。就像在这个例子中: this is how it shows when center item is clicked

我已经从情节提要中添加了标签栏并且它工作正常。 困难的部分是如何保持之前的视图并覆盖动作 sheet。 提前致谢。

您可以简单地创建一个空的视图控制器,并在 viewDidAppear 中显示操作 sheet。但是你必须考虑要做什么(例如要显示哪个视图控制器)

  • 在用户选择一个选项后
  • 如果用户取消操作

使用此委托函数拦截选项卡选择

对于swift 3

func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
    if self.tabBarController.customizableViewControllers.index(of: viewController) == 2 {
       //display action sheet
       return false
    }
    return true
}

对于 objective c

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
//same logic above
}