Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

iPadAir photolibrary issues #153

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions QBImagePicker/QBAlbumsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
contentMode:PHImageContentModeAspectFill
options:nil
resultHandler:^(UIImage *result, NSDictionary *info) {
if(!result){
return;
}
if (cell.tag == indexPath.row) {
cell.imageView3.image = result;
}
Expand All @@ -323,6 +326,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
contentMode:PHImageContentModeAspectFill
options:nil
resultHandler:^(UIImage *result, NSDictionary *info) {
if(!result){
return;
}
if (cell.tag == indexPath.row) {
cell.imageView2.image = result;
}
Expand All @@ -337,6 +343,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
contentMode:PHImageContentModeAspectFill
options:nil
resultHandler:^(UIImage *result, NSDictionary *info) {
if(!result){
return;
}
if (cell.tag == indexPath.row) {
cell.imageView1.image = result;
}
Expand Down
57 changes: 31 additions & 26 deletions QBImagePicker/QBAssetsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -388,30 +388,33 @@ - (void)photoLibraryDidChange:(PHChange *)changeInstance
if (collectionChanges) {
// Get the new fetch result
self.fetchResult = [collectionChanges fetchResultAfterChanges];

if (![collectionChanges hasIncrementalChanges] || [collectionChanges hasMoves]) {
// We need to reload all if the incremental diffs are not available
[self.collectionView reloadData];
} else {
// If we have incremental diffs, tell the collection view to animate insertions and deletions
[self.collectionView performBatchUpdates:^{
NSIndexSet *removedIndexes = [collectionChanges removedIndexes];
if ([removedIndexes count]) {
[self.collectionView deleteItemsAtIndexPaths:[removedIndexes qb_indexPathsFromIndexesWithSection:0]];
}

NSIndexSet *insertedIndexes = [collectionChanges insertedIndexes];
if ([insertedIndexes count]) {
[self.collectionView insertItemsAtIndexPaths:[insertedIndexes qb_indexPathsFromIndexesWithSection:0]];
}

NSIndexSet *changedIndexes = [collectionChanges changedIndexes];
if ([changedIndexes count]) {
[self.collectionView reloadItemsAtIndexPaths:[changedIndexes qb_indexPathsFromIndexesWithSection:0]];
}
} completion:NULL];
}

[self.collectionView reloadData];
// Frequent random crashes on proper animation
// https://rink.hockeyapp.net/manage/apps/45585/app_versions/42/crash_reasons/123652251
// if (![collectionChanges hasIncrementalChanges] || [collectionChanges hasMoves]) {
// // We need to reload all if the incremental diffs are not available
// [self.collectionView reloadData];
// } else {
// // If we have incremental diffs, tell the collection view to animate insertions and deletions
// [self.collectionView performBatchUpdates:^{
// NSIndexSet *removedIndexes = [collectionChanges removedIndexes];
// if ([removedIndexes count]) {
// [self.collectionView deleteItemsAtIndexPaths:[removedIndexes qb_indexPathsFromIndexesWithSection:0]];
// }
//
// NSIndexSet *insertedIndexes = [collectionChanges insertedIndexes];
// if ([insertedIndexes count]) {
// [self.collectionView insertItemsAtIndexPaths:[insertedIndexes qb_indexPathsFromIndexesWithSection:0]];
// }
//
// NSMutableIndexSet *changedIndexes = [collectionChanges changedIndexes].mutableCopy;
// // due https://rink.hockeyapp.net/manage/apps/45585/app_versions/44/crash_reasons/130056083
// [changedIndexes removeIndexes:removedIndexes];
// if ([changedIndexes count]) {
// [self.collectionView reloadItemsAtIndexPaths:[changedIndexes qb_indexPathsFromIndexesWithSection:0]];
// }
// } completion:NULL];
// }
[self resetCachedAssets];
}
});
Expand Down Expand Up @@ -454,6 +457,9 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
contentMode:PHImageContentModeAspectFill
options:nil
resultHandler:^(UIImage *result, NSDictionary *info) {
if(!result){
return;
}
if (cell.tag == indexPath.item) {
cell.imageView.image = result;
}
Expand Down Expand Up @@ -652,8 +658,7 @@ - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollection
numberOfColumns = self.imagePickerController.numberOfColumnsInLandscape;
}

CGFloat width = (CGRectGetWidth(self.view.frame) - 2.0 * (numberOfColumns - 1)) / numberOfColumns;

CGFloat width = MAX(1,(CGRectGetWidth(self.view.frame) - 2.0 * (numberOfColumns - 1)) / numberOfColumns);
return CGSizeMake(width, width);
}

Expand Down