gpt4 book ai didi

objective-c - UIImagePickerController 和横向方向

转载 作者:行者123 更新时间:2023-12-04 18:41:40 26 4
gpt4 key购买 nike

我有一个 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;
}

最佳答案

UIImagePickerController 仅支持 UIInterfaceOrientationPortrait 方向,因此如果它是从横向 View Controller 呈现并不重要,它将以纵向方向显示,即使在 UIInterfaceOrientationPortraitUpsideDown

关于objective-c - UIImagePickerController 和横向方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15217493/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com