How to present UIImagePickerController from tab bar item

和自甴很熟 提交于 2019-12-25 04:36:40

问题


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?

Thanks,

Yusuf


回答1:


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;
}


来源:https://stackoverflow.com/questions/29614978/how-to-present-uiimagepickercontroller-from-tab-bar-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!