UIImagePickerController exposed from the inside

Is it possible to represent the UIImagePickerController inside a view, instead of using it modal or inside a popover?

I have tried this, with no success ...

if ([UIImagePickerController isSourceTypeAvailable:
     UIImagePickerControllerSourceTypePhotoLibrary]) {

    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    NSArray *mediaTypesAllowed = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    [picker setMediaTypes:mediaTypesAllowed];
    picker.delegate = self;

    [picker.view setFrame:CGRectMake(0,0, 400, 400)]; // just for testing
    [picker.view setCenter:CGPointMake(200,200)];

    [myView addSubview:picker.view];
    [picker.view release];

}

      

thanks for any help

+2


a source to share


3 answers


I strongly doubt this is possible without going outside the API.

The main function of the collector view is to securely access a resource for the entire system. In other words, it has a gatekeeper feature that Apple doesn't want any application to override. To restrict access to a photo library, at least it should be modal.



This may be weakening in 4.0, but I doubt it.

0


a source


Can this be done legally?

Yes.

You can use the Image Picker outside of the popover / modal view, this in itself is not illegal, it is simply not supported. Therefore, it is fragile. You won't run into trouble with Apple in this case when submitting your app, but you will want to pay special attention whenever a new version of iOS comes out because it has the potential to break (because it doesn't support using the image picker in another method).

I contacted Apple tech support about this as I also need to implement something similar to the iPad Pages.app popover with segmented control. Using the Image Picker as one of the view elements of the segmented controls.

I have everything up and running, but I couldn't hide the Cancel button in the Image Picker. An Apple engineer told me that this is not a supported solution and also said that Apple "has been known to use private APIs in the past to achieve certain results." I don't think this is a huge surprise. But I'm sure that today, at least, they limit themselves at least to their applications, which they publish in the App Store, in order to use only public APIs.



Bypass

Please check out my git relay on BitBucket, I got this working using view controller containment (which is available since iOS 5).

https://bitbucket.org/danielphillips/image-picker-demo

It also includes a bit of a hack to hide the undo button. It uses an undocumented property, I'm not sure if you could call it a private API, although I've never tried to hack Cocoa Touch private APIs before, and I've never worried about it, so I couldn't tell if it's lightweight hack or if something Apple has detection software, I used a private API.

So, I don't know if hiding part of the Cancel button in the App Store will or not, but it might be worth a try.

+1


a source


Note. There is a minor exception to the popover offs rule that caused an issue in one of my applications. If you have a toolbar, clicking on the toolbar (technically outside the popover =) does not cancel the popover. If you are not coding for this case, it is possible to create two popovers at once that will reject your application ...

0


a source







All Articles