-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
8 changed files
with
117 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,5 +44,4 @@ - (void)selectedIndex:(NSInteger)index { | |
|
||
} | ||
|
||
|
||
@end |
17 changes: 17 additions & 0 deletions
17
YBImageBrowserDemo/Example/用代理配置数据源(以相册为例)/TestFController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// TestFController.h | ||
// YBImageBrowserDemo | ||
// | ||
// Created by 波儿菜 on 2019/8/4. | ||
// Copyright © 2019 杨波. All rights reserved. | ||
// | ||
|
||
#import "BaseListController.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface TestFController : BaseListController | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
75 changes: 75 additions & 0 deletions
75
YBImageBrowserDemo/Example/用代理配置数据源(以相册为例)/TestFController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// | ||
// TestFController.m | ||
// YBImageBrowserDemo | ||
// | ||
// Created by 波儿菜 on 2019/8/4. | ||
// Copyright © 2019 杨波. All rights reserved. | ||
// | ||
|
||
#import "TestFController.h" | ||
#import "YBIBPhotoAlbumManager.h" | ||
#import "YBImageBrowser.h" | ||
#import "YBIBVideoData.h" | ||
|
||
@interface TestFController () <YBImageBrowserDataSource> | ||
|
||
@end | ||
|
||
@implementation TestFController | ||
|
||
#pragma mark - life cycle | ||
|
||
- (instancetype)init { | ||
self = [super init]; | ||
if (self) { | ||
[YBIBPhotoAlbumManager getPhotoAlbumAuthorizationSuccess:^{ | ||
self.dataArray = [BaseFileManager imagePHAssets]; | ||
} failed:^{}]; | ||
} | ||
return self; | ||
} | ||
|
||
+ (NSString *)yb_title { | ||
return @"用代理配置数据源(以相册为例)"; | ||
} | ||
|
||
#pragma mark - override | ||
|
||
- (void)selectedIndex:(NSInteger)index { | ||
|
||
YBImageBrowser *browser = [YBImageBrowser new]; | ||
browser.dataSource = self; | ||
browser.currentPage = index; | ||
[browser show]; | ||
} | ||
|
||
#pragma mark - <YBImageBrowserDataSource> | ||
|
||
- (NSInteger)yb_numberOfCellsInImageBrowser:(YBImageBrowser *)imageBrowser { | ||
return self.dataArray.count; | ||
} | ||
|
||
- (id<YBIBDataProtocol>)yb_imageBrowser:(YBImageBrowser *)imageBrowser dataForCellAtIndex:(NSInteger)index { | ||
|
||
PHAsset *asset = (PHAsset *)self.dataArray[index]; | ||
if (asset.mediaType == PHAssetMediaTypeVideo) { | ||
|
||
// 系统相册的视频 | ||
YBIBVideoData *data = [YBIBVideoData new]; | ||
data.videoPHAsset = asset; | ||
data.projectiveView = [self viewAtIndex:index]; | ||
return data; | ||
|
||
} else if (asset.mediaType == PHAssetMediaTypeImage) { | ||
|
||
// 系统相册的图片 | ||
YBIBImageData *data = [YBIBImageData new]; | ||
data.imagePHAsset = asset; | ||
data.projectiveView = [self viewAtIndex:index]; | ||
return data; | ||
|
||
} | ||
return nil; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters