我有一个 UIImagePicker 来单击图片并从照片库中选择图像。但我的应用程序必须只支持横向。照片库仅通过 ImagePicker 以纵向模式打开。我尝试将当前代码与 ALAssets 集成,但我不知道 AlAssets 库。我想使用图像选择器并使其在 startMediaBrowserFromViewController: 方法中调用 ALAssets。下面是方法定义。请给我一个解决方案。
//pick an image from photo gallery
- (BOOL) startMediaBrowserFromViewController: (UIViewController*) controller
usingDelegate: (id <UIImagePickerControllerDelegate,
UINavigationControllerDelegate>) delegate {
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO)
|| (delegate == nil)
|| (controller == nil))
return NO;
UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
mediaUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
//provides access to photo albums in the device.
mediaUI.mediaTypes=[[[NSArray alloc]initWithObjects:(NSString*)kUTTypeImage,nil]autorelease];
// Hides the controls for moving & scaling pictures.
mediaUI.allowsEditing = NO;
mediaUI.delegate = delegate;
[controller presentModalViewController: mediaUI animated: YES];
return YES;
}