如何从选项卡栏项显示 UIImagePickerController [英] How to present UIImagePickerController from tab bar item
问题描述
我有一个 UITabViewController.I'm trying to modally present a UIImagePickerController when a specific tab bar item is selected.它必须出现在当前的 UIViewController 之上.这就像在 Instagram 或 Periscope 应用程序中按下相机图标时发生的情况一样.但是,我无法弄清楚如何在不显示连接到 Tab Bar Item 的 UIViewController 的情况下显示 UIImagePickerController.这可能吗?
I have a UITabViewController. I'm trying to modally present a UIImagePickerController when a specific tab bar item is selected. It must appear over the current UIViewController. This is like what happens in the Instagram or Periscope app when you press on the camera icon. However I can't figure out how to display the UIImagePickerController without displaying the UIViewController that's connected to the Tab Bar Item. Is this possible?
谢谢,
优素福
推荐答案
你可以使用 UITabBarControllerDelegate
的 shouldSelectViewController
方法来完成这样的事情.
You can use the shouldSelectViewController
method of UITabBarControllerDelegate
to accomplish something like this.
- (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;
}
这篇关于如何从选项卡栏项显示 UIImagePickerController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!