├── SamplePhotosDemo ├── Assets.xcassets │ ├── Contents.json │ └── AppIcon.appiconset │ │ └── Contents.json ├── PhotoAlbumListVC.h ├── AppDelegate.h ├── main.m ├── AssetGridVC.h ├── GridViewCell.h ├── GridViewCell.m ├── Info.plist ├── Base.lproj │ └── LaunchScreen.storyboard ├── AppDelegate.m ├── PhotoAlbumListVC.m └── AssetGridVC.m ├── SamplePhotosDemo.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── project.pbxproj ├── README.md └── .gitignore /SamplePhotosDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /SamplePhotosDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SamplePhotosDemo/PhotoAlbumListVC.h: -------------------------------------------------------------------------------- 1 | // 2 | // PhotoAlbumListVC.h 3 | // SamplePhotosDemo 4 | // 5 | // Created by iTruda on 2018/6/18. 6 | // Copyright © 2018年 iTruda. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PhotoAlbumListVC : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SamplePhotosDemo 2 | 获取手机系统相册照片Demo 3 | 4 | ## Example app using Photos framework 5 | A basic Photos-like app to demonstrate the Photos framework. 6 | 7 | ## Build Requirements 8 | 9 | Xcode 8.0 (iOS 10.0 / tvOS 10.0 SDK) or later 10 | 11 | ## Runtime Requirements 12 | 13 | iOS 10.0, tvOS 10.0, or later 14 | -------------------------------------------------------------------------------- /SamplePhotosDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SamplePhotosDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SamplePhotosDemo 4 | // 5 | // Created by iTruda on 2018/6/18. 6 | // Copyright © 2018年 iTruda. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /SamplePhotosDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SamplePhotosDemo 4 | // 5 | // Created by iTruda on 2018/6/18. 6 | // Copyright © 2018年 iTruda. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SamplePhotosDemo/AssetGridVC.h: -------------------------------------------------------------------------------- 1 | // 2 | // AssetGridVC.h 3 | // SamplePhotosDemo 4 | // 5 | // Created by iTruda on 2018/6/18. 6 | // Copyright © 2018年 iTruda. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface AssetGridVC : UICollectionViewController 13 | 14 | @property (nonatomic, strong) PHFetchResult *fetchResult; 15 | @property (nonatomic, strong) PHAssetCollection *assetCollection; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /SamplePhotosDemo/GridViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // GridViewCell.h 3 | // SamplePhotosDemo 4 | // 5 | // Created by iTruda on 2018/6/18. 6 | // Copyright © 2018年 iTruda. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GridViewCell : UICollectionViewCell 12 | 13 | @property (nonatomic, strong) NSString *representedAssetIdentifier; 14 | @property (nonatomic, strong) UIImage *thumbnailImage; 15 | @property (nonatomic, strong) UIImage *livePhotoBadgeImage; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /SamplePhotosDemo/GridViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // GridViewCell.m 3 | // SamplePhotosDemo 4 | // 5 | // Created by iTruda on 2018/6/18. 6 | // Copyright © 2018年 iTruda. All rights reserved. 7 | // 8 | 9 | #import "GridViewCell.h" 10 | 11 | @interface GridViewCell () 12 | 13 | @property (nonatomic, strong) UIImageView *imageView; 14 | @property (nonatomic, strong) UIImageView *livePhotoBadgeImageView; 15 | 16 | @end 17 | 18 | @implementation GridViewCell 19 | 20 | - (instancetype)initWithFrame:(CGRect)frame 21 | { 22 | self = [super initWithFrame:frame]; 23 | if (self) { 24 | [self initView]; 25 | } 26 | return self; 27 | } 28 | 29 | - (void)initView 30 | { 31 | _imageView = [[UIImageView alloc] initWithFrame:self.bounds]; 32 | _imageView.contentMode = UIViewContentModeScaleAspectFill; 33 | _imageView.clipsToBounds = YES; 34 | [self.contentView addSubview:_imageView]; 35 | 36 | _livePhotoBadgeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 28.f, 28.f)]; 37 | [self.contentView addSubview:_livePhotoBadgeImageView]; 38 | } 39 | 40 | - (void)setThumbnailImage:(UIImage *)thumbnailImage 41 | { 42 | _thumbnailImage = thumbnailImage; 43 | _imageView.image = thumbnailImage; 44 | } 45 | 46 | - (void)setLivePhotoBadgeImage:(UIImage *)livePhotoBadgeImage 47 | { 48 | _livePhotoBadgeImage = livePhotoBadgeImage; 49 | _livePhotoBadgeImageView.image = livePhotoBadgeImage; 50 | } 51 | 52 | - (void)prepareForReuse 53 | { 54 | [super prepareForReuse]; 55 | _imageView.image = nil; 56 | _livePhotoBadgeImageView.image = nil; 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots/**/*.png 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | -------------------------------------------------------------------------------- /SamplePhotosDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleAllowMixedLocalizations 6 | 7 | CFBundleDevelopmentRegion 8 | $(DEVELOPMENT_LANGUAGE) 9 | CFBundleDisplayName 10 | SamplePhotosDemo 11 | CFBundleExecutable 12 | $(EXECUTABLE_NAME) 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | $(PRODUCT_NAME) 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSPhotoLibraryUsageDescription 28 | 需要访问您的相册,请点击允许 29 | UILaunchStoryboardName 30 | LaunchScreen 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /SamplePhotosDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SamplePhotosDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /SamplePhotosDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SamplePhotosDemo 4 | // 5 | // Created by iTruda on 2018/6/18. 6 | // Copyright © 2018年 iTruda. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "PhotoAlbumListVC.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | // Override point for customization after application launch. 21 | 22 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 23 | self.window.backgroundColor = [UIColor whiteColor]; 24 | 25 | PhotoAlbumListVC *rootVC = [[PhotoAlbumListVC alloc] init]; 26 | UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:rootVC];; 27 | self.window.rootViewController = nav; 28 | 29 | [self.window makeKeyAndVisible]; 30 | 31 | return YES; 32 | } 33 | 34 | 35 | - (void)applicationWillResignActive:(UIApplication *)application { 36 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 37 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 38 | } 39 | 40 | 41 | - (void)applicationDidEnterBackground:(UIApplication *)application { 42 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 43 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 44 | } 45 | 46 | 47 | - (void)applicationWillEnterForeground:(UIApplication *)application { 48 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 49 | } 50 | 51 | 52 | - (void)applicationDidBecomeActive:(UIApplication *)application { 53 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 54 | } 55 | 56 | 57 | - (void)applicationWillTerminate:(UIApplication *)application { 58 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 59 | } 60 | 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /SamplePhotosDemo/PhotoAlbumListVC.m: -------------------------------------------------------------------------------- 1 | // 2 | // PhotoAlbumListVC.m 3 | // SamplePhotosDemo 4 | // 5 | // Created by iTruda on 2018/6/18. 6 | // Copyright © 2018年 iTruda. All rights reserved. 7 | // 8 | 9 | #import "PhotoAlbumListVC.h" 10 | #import 11 | #import "AssetGridVC.h" 12 | 13 | typedef NS_ENUM(NSUInteger, RowsInSection) { 14 | allPhotos = 0, 15 | smartAlbums, 16 | userCollections, 17 | }; 18 | 19 | static NSString * const CellID = @"CellID"; 20 | 21 | @interface PhotoAlbumListVC () 22 | 23 | @property (nonatomic, strong) PHFetchResult *allPhotos; 24 | @property (nonatomic, strong) PHFetchResult *smartAlbums; 25 | @property (nonatomic, strong) PHFetchResult *userCollections; 26 | @property (nonatomic, strong) NSArray *sectionLocalizedTitles; 27 | 28 | @end 29 | 30 | @implementation PhotoAlbumListVC 31 | 32 | - (void)dealloc 33 | { 34 | [[PHPhotoLibrary sharedPhotoLibrary] unregisterChangeObserver:self]; 35 | } 36 | 37 | - (void)viewDidLoad { 38 | [super viewDidLoad]; 39 | 40 | // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 41 | // self.navigationItem.rightBarButtonItem = self.editButtonItem; 42 | 43 | [self initData]; 44 | } 45 | 46 | - (void)initData 47 | { 48 | [self fetchAssetCollection]; 49 | 50 | _sectionLocalizedTitles = @[@"", @"Smart Albums", @"Albums"]; 51 | 52 | [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CellID]; 53 | 54 | [[PHPhotoLibrary sharedPhotoLibrary] registerChangeObserver:self]; 55 | } 56 | 57 | - (void)fetchAssetCollection 58 | { 59 | PHFetchOptions *allPhotosOptions = [[PHFetchOptions alloc] init]; 60 | // 按创建时间升序 61 | allPhotosOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:YES]]; 62 | // 获取所有照片(按创建时间升序) 63 | _allPhotos = [PHAsset fetchAssetsWithOptions:allPhotosOptions]; 64 | // 获取所有智能相册 65 | _smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil]; 66 | // 获取所有用户创建相册 67 | _userCollections = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeSmartAlbumUserLibrary options:nil]; 68 | //_userCollections = [PHCollectionList fetchTopLevelUserCollectionsWithOptions:nil]; 69 | } 70 | 71 | #pragma mark - Table view data source 72 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 73 | return 3; 74 | } 75 | 76 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 77 | switch (section) { 78 | case allPhotos: 79 | return 1; 80 | break; 81 | case smartAlbums: 82 | return _smartAlbums.count; 83 | break; 84 | case userCollections: 85 | return _userCollections.count; 86 | break; 87 | } 88 | return 0; 89 | } 90 | 91 | 92 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 93 | { 94 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID forIndexPath:indexPath]; 95 | 96 | switch (indexPath.section) { 97 | case allPhotos: 98 | { 99 | cell.textLabel.text = @"All Photos"; 100 | cell.detailTextLabel.text = [NSString stringWithFormat:@"%zd", _allPhotos.count]; 101 | break; 102 | } 103 | case smartAlbums: 104 | { 105 | PHAssetCollection *collection = [_smartAlbums objectAtIndex:indexPath.row]; 106 | cell.textLabel.text = collection.localizedTitle; 107 | break; 108 | } 109 | case userCollections: 110 | { 111 | PHAssetCollection *collection = [_userCollections objectAtIndex:indexPath.row]; 112 | cell.textLabel.text = collection.localizedTitle; 113 | break; 114 | } 115 | } 116 | 117 | return cell; 118 | } 119 | 120 | - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 121 | { 122 | return _sectionLocalizedTitles[section]; 123 | } 124 | 125 | #pragma mark 126 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 127 | { 128 | UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; 129 | 130 | AssetGridVC *vc = [[AssetGridVC alloc] initWithCollectionViewLayout:layout]; 131 | UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 132 | vc.title = cell.textLabel.text; 133 | PHAssetCollection *collection = nil; 134 | if (indexPath.section == allPhotos) { 135 | vc.fetchResult = _allPhotos; 136 | } 137 | else if (indexPath.section == smartAlbums) { 138 | collection = [_smartAlbums objectAtIndex:indexPath.row]; 139 | } 140 | else if (indexPath.section == userCollections) { 141 | collection = [_userCollections objectAtIndex:indexPath.row]; 142 | } 143 | vc.assetCollection = collection; 144 | vc.fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:nil]; 145 | [self.navigationController pushViewController:vc animated:YES]; 146 | } 147 | 148 | #pragma mark - PHPhotoLibraryChangeObserver - 149 | - (void)photoLibraryDidChange:(PHChange *)changeInstance 150 | { 151 | //第一次安装,点击允许访问后刷新 tableView 152 | //必须在主线程 153 | dispatch_sync(dispatch_get_main_queue(), ^{ 154 | [self fetchAssetCollection]; 155 | [self.tableView reloadData]; 156 | }); 157 | 158 | /* 159 | __weak typeof(self) weakSelf = self; 160 | dispatch_sync(dispatch_get_main_queue(), ^{ 161 | // Check each of the three top-level fetches for changes. 162 | PHFetchResultChangeDetails *changeDetails_allPhotos = [changeInstance changeDetailsForFetchResult:weakSelf.allPhotos]; 163 | if (changeDetails_allPhotos) { 164 | // Update the cached fetch result. 165 | weakSelf.allPhotos = changeDetails_allPhotos.fetchResultAfterChanges; 166 | // (The table row for this one doesn't need updating, it always says "All Photos".) 167 | } 168 | [weakSelf fetchAssetCollection]; 169 | // Update the cached fetch results, and reload the table sections to match. 170 | PHFetchResultChangeDetails *changeDetails_smartAlbums = [changeInstance changeDetailsForFetchResult:weakSelf.smartAlbums]; 171 | if (changeDetails_smartAlbums) { 172 | weakSelf.smartAlbums = changeDetails_allPhotos.fetchResultAfterChanges; 173 | //[weakSelf.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationAutomatic]; 174 | } 175 | PHFetchResultChangeDetails *changeDetails_userCollections = [changeInstance changeDetailsForFetchResult:weakSelf.userCollections]; 176 | if (changeDetails_userCollections) { 177 | // Update the cached fetch result. 178 | weakSelf.userCollections = changeDetails_allPhotos.fetchResultAfterChanges; 179 | //[weakSelf.tableView reloadSections:[NSIndexSet indexSetWithIndex:2] withRowAnimation:UITableViewRowAnimationAutomatic]; 180 | } 181 | [weakSelf.tableView reloadData]; 182 | }); 183 | */ 184 | } 185 | 186 | 187 | /* 188 | // Override to support conditional editing of the table view. 189 | - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { 190 | // Return NO if you do not want the specified item to be editable. 191 | return YES; 192 | } 193 | */ 194 | 195 | /* 196 | // Override to support editing the table view. 197 | - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 198 | if (editingStyle == UITableViewCellEditingStyleDelete) { 199 | // Delete the row from the data source 200 | [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; 201 | } else if (editingStyle == UITableViewCellEditingStyleInsert) { 202 | // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 203 | } 204 | } 205 | */ 206 | 207 | /* 208 | // Override to support rearranging the table view. 209 | - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { 210 | } 211 | */ 212 | 213 | /* 214 | // Override to support conditional rearranging of the table view. 215 | - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { 216 | // Return NO if you do not want the item to be re-orderable. 217 | return YES; 218 | } 219 | */ 220 | 221 | - (void)didReceiveMemoryWarning { 222 | [super didReceiveMemoryWarning]; 223 | // Dispose of any resources that can be recreated. 224 | } 225 | 226 | @end 227 | -------------------------------------------------------------------------------- /SamplePhotosDemo/AssetGridVC.m: -------------------------------------------------------------------------------- 1 | // 2 | // AssetGridVC.m 3 | // SamplePhotosDemo 4 | // 5 | // Created by iTruda on 2018/6/18. 6 | // Copyright © 2018年 iTruda. All rights reserved. 7 | // 8 | 9 | #import "AssetGridVC.h" 10 | #import "GridViewCell.h" 11 | #import 12 | 13 | #define SCR_WIDTH [[UIScreen mainScreen] bounds].size.width 14 | #define SCR_HEIGHT [[UIScreen mainScreen] bounds].size.height 15 | 16 | @interface AssetGridVC () 17 | { 18 | CGSize thumbnailSize; 19 | CGRect previousPreheatRect; 20 | } 21 | 22 | @property (nonatomic, strong) PHCachingImageManager *imageManager; 23 | @property (nonatomic, strong) PHImageRequestOptions *requestOption; 24 | 25 | @end 26 | 27 | @implementation AssetGridVC 28 | 29 | static NSString * const reuseIdentifier = @"Cell"; 30 | 31 | - (void)dealloc 32 | { 33 | 34 | } 35 | 36 | - (void)viewDidLoad { 37 | [super viewDidLoad]; 38 | 39 | // Uncomment the following line to preserve selection between presentations 40 | 41 | [self initData]; 42 | [self initView]; 43 | // Register cell classes 44 | [self.collectionView registerClass:[GridViewCell class] forCellWithReuseIdentifier:reuseIdentifier]; 45 | self.collectionView.dataSource = self; 46 | 47 | // Do any additional setup after loading the view. 48 | } 49 | 50 | - (void)viewWillAppear:(BOOL)animated 51 | { 52 | [super viewWillAppear:animated]; 53 | 54 | CGFloat scale = UIScreen.mainScreen.scale; 55 | CGFloat item_WH = (SCR_WIDTH-20.f-2.f*3)/4.f; 56 | thumbnailSize = CGSizeMake(item_WH * scale, item_WH * scale); 57 | } 58 | 59 | - (void)viewDidAppear:(BOOL)animated 60 | { 61 | [super viewDidAppear:animated]; 62 | [self updateCachedAssets]; 63 | } 64 | 65 | - (void)initData 66 | { 67 | if (!_fetchResult) { 68 | PHFetchOptions *allPhotosOptions = [[PHFetchOptions alloc] init]; 69 | allPhotosOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:YES]]; 70 | _fetchResult = [PHAsset fetchAssetsWithOptions:allPhotosOptions]; 71 | } 72 | 73 | _imageManager = [[PHCachingImageManager alloc] init]; 74 | 75 | _requestOption = [[PHImageRequestOptions alloc] init]; 76 | // 若设置 PHImageRequestOptionsResizeModeExact 则 requestImageForAsset 下来的图片大小是 targetSize 的 77 | _requestOption.resizeMode = PHImageRequestOptionsResizeModeExact; 78 | // 若 _requestOption = nil,则承载图片的 UIImageView 需要添加如下代码 79 | /* 80 | _imageView.contentMode = UIViewContentModeScaleAspectFill; 81 | _imageView.clipsToBounds = YES; 82 | */ 83 | _requestOption = nil; 84 | 85 | [self resetCachedAssets]; 86 | } 87 | 88 | - (void)initView 89 | { 90 | self.view.backgroundColor = [UIColor whiteColor]; 91 | self.collectionView.backgroundColor = [UIColor whiteColor];; 92 | } 93 | 94 | - (void)resetCachedAssets 95 | { 96 | [_imageManager stopCachingImagesForAllAssets]; 97 | previousPreheatRect = CGRectZero; 98 | } 99 | 100 | - (void)updateCachedAssets 101 | { 102 | if (!self.isViewLoaded || self.view.window == nil) { 103 | return; 104 | } 105 | 106 | // 预热区域 preheatRect 是 可见区域 visibleRect 的两倍高 107 | CGRect visibleRect = CGRectMake(0.f, self.collectionView.contentOffset.y, self.collectionView.bounds.size.width, self.collectionView.bounds.size.height); 108 | CGRect preheatRect = CGRectInset(visibleRect, 0, -0.5*visibleRect.size.height); 109 | 110 | // 只有当可见区域与最后一个预热区域显著不同时才更新 111 | CGFloat delta = fabs(CGRectGetMidY(preheatRect) - CGRectGetMidY(previousPreheatRect)); 112 | if (delta > self.view.bounds.size.height / 3.f) { 113 | // 计算开始缓存和停止缓存的区域 114 | [self computeDifferenceBetweenRect:previousPreheatRect andRect:preheatRect removedHandler:^(CGRect removedRect) { 115 | [self imageManagerStopCachingImagesWithRect:removedRect]; 116 | } addedHandler:^(CGRect addedRect) { 117 | [self imageManagerStartCachingImagesWithRect:addedRect]; 118 | }]; 119 | previousPreheatRect = preheatRect; 120 | } 121 | } 122 | 123 | - (void)computeDifferenceBetweenRect:(CGRect)oldRect andRect:(CGRect)newRect removedHandler:(void (^)(CGRect removedRect))removedHandler addedHandler:(void (^)(CGRect addedRect))addedHandler 124 | { 125 | if (CGRectIntersectsRect(newRect, oldRect)) { 126 | CGFloat oldMaxY = CGRectGetMaxY(oldRect); 127 | CGFloat oldMinY = CGRectGetMinY(oldRect); 128 | CGFloat newMaxY = CGRectGetMaxY(newRect); 129 | CGFloat newMinY = CGRectGetMinY(newRect); 130 | //添加 向下滑动时 newRect 除去与 oldRect 相交部分的区域(即:屏幕外底部的预热区域) 131 | if (newMaxY > oldMaxY) { 132 | CGRect rectToAdd = CGRectMake(newRect.origin.x, oldMaxY, newRect.size.width, (newMaxY - oldMaxY)); 133 | addedHandler(rectToAdd); 134 | } 135 | //添加 向上滑动时 newRect 除去与 oldRect 相交部分的区域(即:屏幕外底部的预热区域) 136 | if (oldMinY > newMinY) { 137 | CGRect rectToAdd = CGRectMake(newRect.origin.x, newMinY, newRect.size.width, (oldMinY - newMinY)); 138 | addedHandler(rectToAdd); 139 | } 140 | //移除 向上滑动时 oldRect 除去与 newRect 相交部分的区域(即:屏幕外底部的预热区域) 141 | if (newMaxY < oldMaxY) { 142 | CGRect rectToRemove = CGRectMake(newRect.origin.x, newMaxY, newRect.size.width, (oldMaxY - newMaxY)); 143 | removedHandler(rectToRemove); 144 | } 145 | //移除 向下滑动时 oldRect 除去与 newRect 相交部分的区域(即:屏幕外顶部的预热区域) 146 | if (oldMinY < newMinY) { 147 | CGRect rectToRemove = CGRectMake(newRect.origin.x, oldMinY, newRect.size.width, (newMinY - oldMinY)); 148 | removedHandler(rectToRemove); 149 | } 150 | } 151 | else { 152 | //当 oldRect 与 newRect 没有相交区域时 153 | addedHandler(newRect); 154 | removedHandler(oldRect); 155 | } 156 | } 157 | 158 | - (void)imageManagerStartCachingImagesWithRect:(CGRect)rect 159 | { 160 | NSMutableArray *addAssets = [self indexPathsForElementsWithRect:rect]; 161 | [_imageManager startCachingImagesForAssets:addAssets targetSize:thumbnailSize contentMode:PHImageContentModeAspectFill options:_requestOption]; 162 | } 163 | 164 | - (void)imageManagerStopCachingImagesWithRect:(CGRect)rect 165 | { 166 | NSMutableArray *removeAssets = [self indexPathsForElementsWithRect:rect]; 167 | [_imageManager stopCachingImagesForAssets:removeAssets targetSize:thumbnailSize contentMode:PHImageContentModeAspectFill options:_requestOption]; 168 | } 169 | 170 | - (NSMutableArray *)indexPathsForElementsWithRect:(CGRect)rect 171 | { 172 | UICollectionViewLayout *layout = self.collectionView.collectionViewLayout; 173 | NSArray<__kindof UICollectionViewLayoutAttributes *> *layoutAttributes = [layout layoutAttributesForElementsInRect:rect]; 174 | NSMutableArray *assets = [NSMutableArray array]; 175 | for (__kindof UICollectionViewLayoutAttributes *layoutAttr in layoutAttributes) { 176 | NSIndexPath *indexPath = layoutAttr.indexPath; 177 | PHAsset *asset = [_fetchResult objectAtIndex:indexPath.item]; 178 | [assets addObject:asset]; 179 | } 180 | return assets; 181 | } 182 | 183 | #pragma mark - UIScrollViewDelegate - 184 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView 185 | { 186 | [self updateCachedAssets]; 187 | } 188 | 189 | #pragma mark 190 | 191 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 192 | { 193 | return _fetchResult.count; 194 | } 195 | 196 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 197 | { 198 | GridViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; 199 | 200 | PHAsset *asset = [_fetchResult objectAtIndex:indexPath.item]; 201 | // 给 Live Photo 添加一个标记 202 | if (@available(iOS 9.1, *)) { 203 | if (asset.mediaSubtypes == PHAssetMediaSubtypePhotoLive) { 204 | cell.livePhotoBadgeImage = [PHLivePhotoView livePhotoBadgeImageWithOptions:PHLivePhotoBadgeOptionsOverContent]; 205 | } 206 | } 207 | 208 | cell.representedAssetIdentifier = asset.localIdentifier; 209 | 210 | // targetSize 是以像素计量的,所以需要实际的 size * UIScreen.mainScreen.scale 211 | [_imageManager requestImageForAsset:asset targetSize:thumbnailSize contentMode:PHImageContentModeAspectFill options:_requestOption resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) { 212 | // 当 resultHandler 被调用时,cell可能已被回收,所以此处加个判断条件 213 | if ([cell.representedAssetIdentifier isEqualToString:asset.localIdentifier]) { 214 | cell.thumbnailImage = result; 215 | } 216 | }]; 217 | 218 | return cell; 219 | } 220 | 221 | #pragma mark 222 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath 223 | { 224 | CGFloat item_WH = (SCR_WIDTH-20.f-2.f*3)/4.f; 225 | return CGSizeMake(item_WH, item_WH); 226 | } 227 | 228 | - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section 229 | { 230 | return UIEdgeInsetsMake(0, 10.f, 10.f, 10.f); 231 | } 232 | 233 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section 234 | { 235 | return 2.f; 236 | } 237 | 238 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section 239 | { 240 | return 2.f; 241 | } 242 | 243 | #pragma mark 244 | 245 | /* 246 | // Uncomment this method to specify if the specified item should be highlighted during tracking 247 | - (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath { 248 | return YES; 249 | } 250 | */ 251 | 252 | /* 253 | // Uncomment this method to specify if the specified item should be selected 254 | - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath { 255 | return YES; 256 | } 257 | */ 258 | 259 | /* 260 | // Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item 261 | - (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath { 262 | return NO; 263 | } 264 | 265 | - (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender { 266 | return NO; 267 | } 268 | 269 | - (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender { 270 | 271 | } 272 | */ 273 | 274 | 275 | - (void)didReceiveMemoryWarning { 276 | [super didReceiveMemoryWarning]; 277 | // Dispose of any resources that can be recreated. 278 | } 279 | 280 | @end 281 | -------------------------------------------------------------------------------- /SamplePhotosDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1497A81E20D92D4C008E8493 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 1497A81D20D92D4C008E8493 /* README.md */; }; 11 | 14AB939E20D7412D00AA232B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 14AB939D20D7412D00AA232B /* AppDelegate.m */; }; 12 | 14AB93A620D7412E00AA232B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 14AB93A520D7412E00AA232B /* Assets.xcassets */; }; 13 | 14AB93A920D7412E00AA232B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 14AB93A720D7412E00AA232B /* LaunchScreen.storyboard */; }; 14 | 14AB93AC20D7412E00AA232B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 14AB93AB20D7412E00AA232B /* main.m */; }; 15 | 14AB93B720D7438A00AA232B /* PhotoAlbumListVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 14AB93B620D7438A00AA232B /* PhotoAlbumListVC.m */; }; 16 | 14AB93BA20D774DD00AA232B /* AssetGridVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 14AB93B920D774DD00AA232B /* AssetGridVC.m */; }; 17 | 14AB93BD20D77A0C00AA232B /* GridViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 14AB93BC20D77A0C00AA232B /* GridViewCell.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | 1497A81D20D92D4C008E8493 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; }; 22 | 14AB939920D7412D00AA232B /* SamplePhotosDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SamplePhotosDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | 14AB939C20D7412D00AA232B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 24 | 14AB939D20D7412D00AA232B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 25 | 14AB93A520D7412E00AA232B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 26 | 14AB93A820D7412E00AA232B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 27 | 14AB93AA20D7412E00AA232B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 28 | 14AB93AB20D7412E00AA232B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 29 | 14AB93B520D7438A00AA232B /* PhotoAlbumListVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PhotoAlbumListVC.h; sourceTree = ""; }; 30 | 14AB93B620D7438A00AA232B /* PhotoAlbumListVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PhotoAlbumListVC.m; sourceTree = ""; }; 31 | 14AB93B820D774DD00AA232B /* AssetGridVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AssetGridVC.h; sourceTree = ""; }; 32 | 14AB93B920D774DD00AA232B /* AssetGridVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AssetGridVC.m; sourceTree = ""; }; 33 | 14AB93BB20D77A0C00AA232B /* GridViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GridViewCell.h; sourceTree = ""; }; 34 | 14AB93BC20D77A0C00AA232B /* GridViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GridViewCell.m; sourceTree = ""; }; 35 | /* End PBXFileReference section */ 36 | 37 | /* Begin PBXFrameworksBuildPhase section */ 38 | 14AB939620D7412D00AA232B /* Frameworks */ = { 39 | isa = PBXFrameworksBuildPhase; 40 | buildActionMask = 2147483647; 41 | files = ( 42 | ); 43 | runOnlyForDeploymentPostprocessing = 0; 44 | }; 45 | /* End PBXFrameworksBuildPhase section */ 46 | 47 | /* Begin PBXGroup section */ 48 | 14AB939020D7412D00AA232B = { 49 | isa = PBXGroup; 50 | children = ( 51 | 14AB939B20D7412D00AA232B /* SamplePhotosDemo */, 52 | 14AB939A20D7412D00AA232B /* Products */, 53 | ); 54 | sourceTree = ""; 55 | }; 56 | 14AB939A20D7412D00AA232B /* Products */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 14AB939920D7412D00AA232B /* SamplePhotosDemo.app */, 60 | ); 61 | name = Products; 62 | sourceTree = ""; 63 | }; 64 | 14AB939B20D7412D00AA232B /* SamplePhotosDemo */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 14AB939C20D7412D00AA232B /* AppDelegate.h */, 68 | 14AB939D20D7412D00AA232B /* AppDelegate.m */, 69 | 14AB93B520D7438A00AA232B /* PhotoAlbumListVC.h */, 70 | 14AB93B620D7438A00AA232B /* PhotoAlbumListVC.m */, 71 | 14AB93B820D774DD00AA232B /* AssetGridVC.h */, 72 | 14AB93B920D774DD00AA232B /* AssetGridVC.m */, 73 | 14AB93BB20D77A0C00AA232B /* GridViewCell.h */, 74 | 14AB93BC20D77A0C00AA232B /* GridViewCell.m */, 75 | 14AB93A520D7412E00AA232B /* Assets.xcassets */, 76 | 14AB93A720D7412E00AA232B /* LaunchScreen.storyboard */, 77 | 14AB93AA20D7412E00AA232B /* Info.plist */, 78 | 14AB93AB20D7412E00AA232B /* main.m */, 79 | 1497A81D20D92D4C008E8493 /* README.md */, 80 | ); 81 | path = SamplePhotosDemo; 82 | sourceTree = ""; 83 | }; 84 | /* End PBXGroup section */ 85 | 86 | /* Begin PBXNativeTarget section */ 87 | 14AB939820D7412D00AA232B /* SamplePhotosDemo */ = { 88 | isa = PBXNativeTarget; 89 | buildConfigurationList = 14AB93AF20D7412E00AA232B /* Build configuration list for PBXNativeTarget "SamplePhotosDemo" */; 90 | buildPhases = ( 91 | 14AB939520D7412D00AA232B /* Sources */, 92 | 14AB939620D7412D00AA232B /* Frameworks */, 93 | 14AB939720D7412D00AA232B /* Resources */, 94 | ); 95 | buildRules = ( 96 | ); 97 | dependencies = ( 98 | ); 99 | name = SamplePhotosDemo; 100 | productName = SamplePhotosDemo; 101 | productReference = 14AB939920D7412D00AA232B /* SamplePhotosDemo.app */; 102 | productType = "com.apple.product-type.application"; 103 | }; 104 | /* End PBXNativeTarget section */ 105 | 106 | /* Begin PBXProject section */ 107 | 14AB939120D7412D00AA232B /* Project object */ = { 108 | isa = PBXProject; 109 | attributes = { 110 | LastUpgradeCheck = 0940; 111 | ORGANIZATIONNAME = iTruda; 112 | TargetAttributes = { 113 | 14AB939820D7412D00AA232B = { 114 | CreatedOnToolsVersion = 9.4; 115 | }; 116 | }; 117 | }; 118 | buildConfigurationList = 14AB939420D7412D00AA232B /* Build configuration list for PBXProject "SamplePhotosDemo" */; 119 | compatibilityVersion = "Xcode 9.3"; 120 | developmentRegion = en; 121 | hasScannedForEncodings = 0; 122 | knownRegions = ( 123 | en, 124 | Base, 125 | ); 126 | mainGroup = 14AB939020D7412D00AA232B; 127 | productRefGroup = 14AB939A20D7412D00AA232B /* Products */; 128 | projectDirPath = ""; 129 | projectRoot = ""; 130 | targets = ( 131 | 14AB939820D7412D00AA232B /* SamplePhotosDemo */, 132 | ); 133 | }; 134 | /* End PBXProject section */ 135 | 136 | /* Begin PBXResourcesBuildPhase section */ 137 | 14AB939720D7412D00AA232B /* Resources */ = { 138 | isa = PBXResourcesBuildPhase; 139 | buildActionMask = 2147483647; 140 | files = ( 141 | 1497A81E20D92D4C008E8493 /* README.md in Resources */, 142 | 14AB93A920D7412E00AA232B /* LaunchScreen.storyboard in Resources */, 143 | 14AB93A620D7412E00AA232B /* Assets.xcassets in Resources */, 144 | ); 145 | runOnlyForDeploymentPostprocessing = 0; 146 | }; 147 | /* End PBXResourcesBuildPhase section */ 148 | 149 | /* Begin PBXSourcesBuildPhase section */ 150 | 14AB939520D7412D00AA232B /* Sources */ = { 151 | isa = PBXSourcesBuildPhase; 152 | buildActionMask = 2147483647; 153 | files = ( 154 | 14AB93B720D7438A00AA232B /* PhotoAlbumListVC.m in Sources */, 155 | 14AB93AC20D7412E00AA232B /* main.m in Sources */, 156 | 14AB939E20D7412D00AA232B /* AppDelegate.m in Sources */, 157 | 14AB93BD20D77A0C00AA232B /* GridViewCell.m in Sources */, 158 | 14AB93BA20D774DD00AA232B /* AssetGridVC.m in Sources */, 159 | ); 160 | runOnlyForDeploymentPostprocessing = 0; 161 | }; 162 | /* End PBXSourcesBuildPhase section */ 163 | 164 | /* Begin PBXVariantGroup section */ 165 | 14AB93A720D7412E00AA232B /* LaunchScreen.storyboard */ = { 166 | isa = PBXVariantGroup; 167 | children = ( 168 | 14AB93A820D7412E00AA232B /* Base */, 169 | ); 170 | name = LaunchScreen.storyboard; 171 | sourceTree = ""; 172 | }; 173 | /* End PBXVariantGroup section */ 174 | 175 | /* Begin XCBuildConfiguration section */ 176 | 14AB93AD20D7412E00AA232B /* Debug */ = { 177 | isa = XCBuildConfiguration; 178 | buildSettings = { 179 | ALWAYS_SEARCH_USER_PATHS = NO; 180 | CLANG_ANALYZER_NONNULL = YES; 181 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 182 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 183 | CLANG_CXX_LIBRARY = "libc++"; 184 | CLANG_ENABLE_MODULES = YES; 185 | CLANG_ENABLE_OBJC_ARC = YES; 186 | CLANG_ENABLE_OBJC_WEAK = YES; 187 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 188 | CLANG_WARN_BOOL_CONVERSION = YES; 189 | CLANG_WARN_COMMA = YES; 190 | CLANG_WARN_CONSTANT_CONVERSION = YES; 191 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 192 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 193 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 194 | CLANG_WARN_EMPTY_BODY = YES; 195 | CLANG_WARN_ENUM_CONVERSION = YES; 196 | CLANG_WARN_INFINITE_RECURSION = YES; 197 | CLANG_WARN_INT_CONVERSION = YES; 198 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 199 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 200 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 201 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 202 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 203 | CLANG_WARN_STRICT_PROTOTYPES = YES; 204 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 205 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 206 | CLANG_WARN_UNREACHABLE_CODE = YES; 207 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 208 | CODE_SIGN_IDENTITY = "iPhone Developer"; 209 | COPY_PHASE_STRIP = NO; 210 | DEBUG_INFORMATION_FORMAT = dwarf; 211 | ENABLE_STRICT_OBJC_MSGSEND = YES; 212 | ENABLE_TESTABILITY = YES; 213 | GCC_C_LANGUAGE_STANDARD = gnu11; 214 | GCC_DYNAMIC_NO_PIC = NO; 215 | GCC_NO_COMMON_BLOCKS = YES; 216 | GCC_OPTIMIZATION_LEVEL = 0; 217 | GCC_PREPROCESSOR_DEFINITIONS = ( 218 | "DEBUG=1", 219 | "$(inherited)", 220 | ); 221 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 222 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 223 | GCC_WARN_UNDECLARED_SELECTOR = YES; 224 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 225 | GCC_WARN_UNUSED_FUNCTION = YES; 226 | GCC_WARN_UNUSED_VARIABLE = YES; 227 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 228 | MTL_ENABLE_DEBUG_INFO = YES; 229 | ONLY_ACTIVE_ARCH = YES; 230 | SDKROOT = iphoneos; 231 | }; 232 | name = Debug; 233 | }; 234 | 14AB93AE20D7412E00AA232B /* Release */ = { 235 | isa = XCBuildConfiguration; 236 | buildSettings = { 237 | ALWAYS_SEARCH_USER_PATHS = NO; 238 | CLANG_ANALYZER_NONNULL = YES; 239 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 240 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 241 | CLANG_CXX_LIBRARY = "libc++"; 242 | CLANG_ENABLE_MODULES = YES; 243 | CLANG_ENABLE_OBJC_ARC = YES; 244 | CLANG_ENABLE_OBJC_WEAK = YES; 245 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 246 | CLANG_WARN_BOOL_CONVERSION = YES; 247 | CLANG_WARN_COMMA = YES; 248 | CLANG_WARN_CONSTANT_CONVERSION = YES; 249 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 250 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 251 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 252 | CLANG_WARN_EMPTY_BODY = YES; 253 | CLANG_WARN_ENUM_CONVERSION = YES; 254 | CLANG_WARN_INFINITE_RECURSION = YES; 255 | CLANG_WARN_INT_CONVERSION = YES; 256 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 257 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 258 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 259 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 260 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 261 | CLANG_WARN_STRICT_PROTOTYPES = YES; 262 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 263 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 264 | CLANG_WARN_UNREACHABLE_CODE = YES; 265 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 266 | CODE_SIGN_IDENTITY = "iPhone Developer"; 267 | COPY_PHASE_STRIP = NO; 268 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 269 | ENABLE_NS_ASSERTIONS = NO; 270 | ENABLE_STRICT_OBJC_MSGSEND = YES; 271 | GCC_C_LANGUAGE_STANDARD = gnu11; 272 | GCC_NO_COMMON_BLOCKS = YES; 273 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 274 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 275 | GCC_WARN_UNDECLARED_SELECTOR = YES; 276 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 277 | GCC_WARN_UNUSED_FUNCTION = YES; 278 | GCC_WARN_UNUSED_VARIABLE = YES; 279 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 280 | MTL_ENABLE_DEBUG_INFO = NO; 281 | SDKROOT = iphoneos; 282 | VALIDATE_PRODUCT = YES; 283 | }; 284 | name = Release; 285 | }; 286 | 14AB93B020D7412E00AA232B /* Debug */ = { 287 | isa = XCBuildConfiguration; 288 | buildSettings = { 289 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 290 | CODE_SIGN_STYLE = Automatic; 291 | DEVELOPMENT_TEAM = 32FNPEZ956; 292 | INFOPLIST_FILE = SamplePhotosDemo/Info.plist; 293 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 294 | LD_RUNPATH_SEARCH_PATHS = ( 295 | "$(inherited)", 296 | "@executable_path/Frameworks", 297 | ); 298 | PRODUCT_BUNDLE_IDENTIFIER = com.iTruda.SamplePhotosDemo; 299 | PRODUCT_NAME = "$(TARGET_NAME)"; 300 | TARGETED_DEVICE_FAMILY = 1; 301 | }; 302 | name = Debug; 303 | }; 304 | 14AB93B120D7412E00AA232B /* Release */ = { 305 | isa = XCBuildConfiguration; 306 | buildSettings = { 307 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 308 | CODE_SIGN_STYLE = Automatic; 309 | DEVELOPMENT_TEAM = 32FNPEZ956; 310 | INFOPLIST_FILE = SamplePhotosDemo/Info.plist; 311 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 312 | LD_RUNPATH_SEARCH_PATHS = ( 313 | "$(inherited)", 314 | "@executable_path/Frameworks", 315 | ); 316 | PRODUCT_BUNDLE_IDENTIFIER = com.iTruda.SamplePhotosDemo; 317 | PRODUCT_NAME = "$(TARGET_NAME)"; 318 | TARGETED_DEVICE_FAMILY = 1; 319 | }; 320 | name = Release; 321 | }; 322 | /* End XCBuildConfiguration section */ 323 | 324 | /* Begin XCConfigurationList section */ 325 | 14AB939420D7412D00AA232B /* Build configuration list for PBXProject "SamplePhotosDemo" */ = { 326 | isa = XCConfigurationList; 327 | buildConfigurations = ( 328 | 14AB93AD20D7412E00AA232B /* Debug */, 329 | 14AB93AE20D7412E00AA232B /* Release */, 330 | ); 331 | defaultConfigurationIsVisible = 0; 332 | defaultConfigurationName = Release; 333 | }; 334 | 14AB93AF20D7412E00AA232B /* Build configuration list for PBXNativeTarget "SamplePhotosDemo" */ = { 335 | isa = XCConfigurationList; 336 | buildConfigurations = ( 337 | 14AB93B020D7412E00AA232B /* Debug */, 338 | 14AB93B120D7412E00AA232B /* Release */, 339 | ); 340 | defaultConfigurationIsVisible = 0; 341 | defaultConfigurationName = Release; 342 | }; 343 | /* End XCConfigurationList section */ 344 | }; 345 | rootObject = 14AB939120D7412D00AA232B /* Project object */; 346 | } 347 | --------------------------------------------------------------------------------