0
的alasset我得到用戶ALAssetsLibrary與此代碼enumerateAssetsWithOptions返回nil
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
// Enumerate just the photos and videos group by using ALAssetsGroupSavedPhotos.
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
// Within the group enumeration block, filter to enumerate just photos.
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
// Chooses the photo at the last index
[group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *alAsset, NSUInteger index, BOOL *innerStop) {
// The end of the enumeration is signaled by asset == nil.
if (alAsset) {
,從時間到時間alasset回報作爲零,我不知道爲什麼的問題。我試過的大多數手機都能正常工作,但由於某種原因,其他手機的alasset只是以零的形式返回。
所有手機都是iOS版本嗎?你在調試輸出中看到任何警告嗎?他們是否都授予照片訪問權限? – 2014-10-17 19:14:47
當'alAsset'爲'nil'時'index'的值是多少? – rmaddy 2014-10-17 20:05:48
我不確定,因爲它在手機中,我沒有訪問權限。我試圖在模擬器中獲得相同的結果,索引號爲9223372036854775807. 當alAsset爲零且索引有值時,意味着什麼? – 2014-10-17 21:02:42