如何从选项卡栏项显示 UIImagePickerController [英] How to present UIImagePickerController from tab bar item

查看:35
本文介绍了如何从选项卡栏项显示 UIImagePickerController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 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?

谢谢,

优素福

推荐答案

你可以使用 UITabBarControllerDelegateshouldSelectViewController 方法来完成这样的事情.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆