问题
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