【问题标题】:How to present UIImagePickerController from tab bar item如何从标签栏项目呈现 UIImagePickerController
【发布时间】:2015-04-13 20:58:22
【问题描述】:
我有一个 UITabViewController。 I'm trying to modally present a UIImagePickerController when a specific tab bar item is selected.它必须出现在当前 UIViewController 上。这就像您按下相机图标时在 Instagram 或 Periscope 应用程序中发生的情况一样。但是,我不知道如何在不显示连接到选项卡栏项的 UIViewController 的情况下显示 UIImagePickerController。这可能吗?
谢谢,
优素福
【问题讨论】:
标签:
ios
objective-c
swift
uitabbarcontroller
uitabbaritem
【解决方案1】:
您可以使用UITabBarControllerDelegate 的shouldSelectViewController 方法来完成这样的事情。
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
// Check if it's the "image picker" tab
if (viewController == self.imagePickerTabView) {
// Present image picker
return NO;
}
// All other cases switch to the tab
return YES;
}