ios - 如何防止用户同时从图像库中选择和交换图像,使其不进入编辑 View ?
<p><p>我在从 iPhone(iOS 8.4) 的图像库中选择图像时遇到问题。</p>
<p><strong>这是我的代码:</strong></p>
<pre><code> UIImagePickerController *imagePicker = [ init];
imagePicker.delegate = self;
imagePicker.allowsEditing = NO;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
;
</code></pre>
<p>但是,如果我同时选择一个图像并交换该图像,它会打开一个编辑 View ,然后如果我尝试删除该图像,我的应用程序就会崩溃。</p>
<p>它是图片库的默认功能吗?还是可以通过代码来处理?</p>
<p>请告诉我。
提前致谢</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>如果你可以尝试</p>
<pre><code>NSMutableArray *assetGroups = [ init];
void (^assetGroupEnumerator) (ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
{
if(group != nil)
{
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
{
//ALAssetRepresentation holds all the information about the asset being accessed.
if(result)
{
ALAssetRepresentation *representation = ;
if (representation !=nil)
{
UIImage *PhotoThumbnail = ];
;
UIImage * latestPhoto = ];
;
}
}
}];
;
}
galleryImagesCV.hidden=NO;
;
};
assetGroups = [ init];
ALAssetsLibrary *library = [ init];
NSUInteger groupTypes = ALAssetsGroupSavedPhotos;
[library enumerateGroupsWithTypes:groupTypes usingBlock:assetGroupEnumerator failureBlock:^(NSError *error)
{
NSLog(@"A problem occurred");
}];
</code></pre>
<p>导入 AssetsLibrary/AssetsLibrary.h</p>
<p>这将为您提供数组中图库中的所有图像。您可以在自定义 View 中显示这些并选择/交换等。</p>
<p>希望对你有帮助</p></p>
<p style="font-size: 20px;">关于ios - 如何防止用户同时从图像库中选择和交换图像,使其不进入编辑 View ?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/37982040/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/37982040/
</a>
</p>
页:
[1]