0

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

Tometoyou
  • 7,792
  • 12
  • 62
  • 108

1 Answers1

2

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;
}
DanielG
  • 2,237
  • 1
  • 19
  • 19