Skip to content

Instantly share code, notes, and snippets.

@ddeville
Last active December 17, 2015 20:49
Show Gist options
  • Save ddeville/5670475 to your computer and use it in GitHub Desktop.
Save ddeville/5670475 to your computer and use it in GitHub Desktop.
Caution: this is very very nasty...
@interface SomeViewController : UIViewController
@end
@implementation SomeViewController
- (IBAction)show:(id)sender
{
UIImagePickerController *pickerController = [UIImagePickerController new];
[pickerController setDelegate:(id)self];
[self presentViewController:pickerController animated:YES completion:nil];
}
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if ([viewController isKindOfClass:NSClassFromString(@"PLUIAlbumViewController")]) {
/*
The custom view on the navigationItem is set up in loadView so the view
needs to be loaded.
*/
(void)[viewController view];
/*
At this stage, with the view loaded, if you do:
po [[viewController navigationItem] rightBarButtonItems]
you will indeed get nil.
But if you do:
po [[viewController navigationItem] _customRightViews]
you will get the UINavigationButton that is currently displayed.
*/
[[[viewController navigationItem] valueForKey:@"_customRightViews"] enumerateObjectsUsingBlock:^ (UIView *view, NSUInteger idx, BOOL *stop) {
[view setHidden:YES];
}];
}
}
@end
@danielphillips
Copy link

Interesting hack. I contacted Apple about this. Citing Pages and they told me they used private APIs to do that. But they also said this was "in the past" and they only use public APIs now in their apps. Will be interesting to see if there's an update to the iWork iOS suite if this image picker changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment