views:

300

answers:

2

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

I have tried this, without 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

A: 

I strongly doubt it's possible without going outside the API.

The primary function of the picker view is to safely provide access to a system wide resource. In other words, it has a gatekeeper function that Apple doesn't want any app to be able to override. To enforce it's restrictions on access to the photolibrary at least, it has to be modal.

That might loosen up in 4.0 but I kind of doubt it.

TechZen
but on iPad you can present it on a popover that is not modal...
Digital Robot
A popover itself is effectively modal. You can see the rest of the interface but the popover traps all touches. Tapping outside the popover dismisses it.
TechZen
I'm not sure if it's possible to present it in an arbitrary view (I am looking as well) but with respect to access and 4.0 that has changed. In 4.0 you can use the Asset Library classes to enumerate photos and videos and access them programmatically. I believe this means that you could write your own image browser pretty easily. See: http://developer.apple.com/iphone/library/documentation./AssetsLibrary/Reference/AssetsLibraryFramework/index.html
Pat Niemeyer
I haven't fiddle with the asset Library yet but if it allows arbitrary access to media: (1) I will be surprised and (2) happy. Apple has demonstrated a high degree of privacy/security concern/paranoia with iOS. Perhaps all the new under the hood security stuff will let them ease up on the developer's restrictions.
TechZen
A: 

Note: There is a minor exception to the "tapping outside a popover dismisses it" rule, which caused a problem in one of my app submissions. If you have a toolbar, tapping on the toolbar (which is technically outside the popover =) does not dismiss the popover. If you don't code for this case, it's possible to spawn two popovers at once, which will get your app rejected...

gulchrider