Skip to content

Commit

Permalink
[fix] 增加隐藏图片浏览器接口;修复系统语言判断的BUG。 fixed #176 #181
Browse files Browse the repository at this point in the history
  • Loading branch information
indulgeIn committed Aug 4, 2019
1 parent d57ddac commit 9ab503d
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 5 deletions.
3 changes: 1 addition & 2 deletions YBImageBrowser/Helper/YBIBCopywriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ - (instancetype)init {
NSArray *appleLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
if (appleLanguages && appleLanguages.count > 0) {
NSString *languages = appleLanguages[0];
if (![languages isEqualToString:@"zh-Hans-CN"]) {
if (![languages hasPrefix:@"zh-Hans"]) {
_type = YBIBCopywriterTypeEnglish;
}
}
Expand Down Expand Up @@ -62,5 +62,4 @@ - (void)setType:(YBIBCopywriterType)type {
[self initCopy];
}


@end
5 changes: 5 additions & 0 deletions YBImageBrowser/YBImageBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ NS_ASSUME_NONNULL_BEGIN
- (void)showToView:(UIView *)view;
- (void)show;

/**
隐藏图片浏览器(不建议外部持有图片浏览器重复使用)
*/
- (void)hide;

/// 当前页码
@property (nonatomic, assign) NSInteger currentPage;

Expand Down
4 changes: 3 additions & 1 deletion YBImageBrowser/YBImageBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ - (void)rebuild {
self.hiddenProjectiveView = nil;
[self showStatusBar];
[self.containerView removeFromSuperview];
self.collectionView = nil;
_containerView = nil;
[self.collectionView removeFromSuperview];
_collectionView = nil;
[self.dataMediator clear];
[self.rotationHandler clear];
}
Expand Down
14 changes: 14 additions & 0 deletions YBImageBrowserDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
23F26ACC22D71FB200C27C21 /* YBIBVideoView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23F26ACB22D71FB200C27C21 /* YBIBVideoView.m */; };
23F26ACF22D7206900C27C21 /* YBIBVideoTopBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 23F26ACE22D7206900C27C21 /* YBIBVideoTopBar.m */; };
23F26AD222D7208700C27C21 /* YBIBVideoActionBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 23F26AD122D7208700C27C21 /* YBIBVideoActionBar.m */; };
23FF103622F6B6FC0091331F /* TestFController.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF103522F6B6FC0091331F /* TestFController.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -210,6 +211,8 @@
23F26ACE22D7206900C27C21 /* YBIBVideoTopBar.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YBIBVideoTopBar.m; sourceTree = "<group>"; };
23F26AD022D7208700C27C21 /* YBIBVideoActionBar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YBIBVideoActionBar.h; sourceTree = "<group>"; };
23F26AD122D7208700C27C21 /* YBIBVideoActionBar.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YBIBVideoActionBar.m; sourceTree = "<group>"; };
23FF103422F6B6FC0091331F /* TestFController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TestFController.h; sourceTree = "<group>"; };
23FF103522F6B6FC0091331F /* TestFController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestFController.m; sourceTree = "<group>"; };
97542AA3FE46C41411B15C5D /* Pods_YBImageBrowserDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_YBImageBrowserDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B7455F1D491BFCA198544CA1 /* Pods-YBImageBrowserDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-YBImageBrowserDemo.debug.xcconfig"; path = "Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo.debug.xcconfig"; sourceTree = "<group>"; };
F2A1E10DD2C568E5493980E0 /* Pods-YBImageBrowserDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-YBImageBrowserDemo.release.xcconfig"; path = "Target Support Files/Pods-YBImageBrowserDemo/Pods-YBImageBrowserDemo.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -429,6 +432,7 @@
23CC34E622DC4B070037018B /* 自定义工具视图(例查看原图) */,
23CC34E722DC4B570037018B /* 自定义 Cell */,
23CC34E522DC49CC0037018B /* 图片显示预处理(例添加水印) */,
23FF103322F6B6BF0091331F /* 用代理配置数据源(以相册为例) */,
23CC34D822DC25450037018B /* 添加到控制器使用(以相册为例) */,
);
path = Example;
Expand Down Expand Up @@ -515,6 +519,15 @@
path = File;
sourceTree = "<group>";
};
23FF103322F6B6BF0091331F /* 用代理配置数据源(以相册为例) */ = {
isa = PBXGroup;
children = (
23FF103422F6B6FC0091331F /* TestFController.h */,
23FF103522F6B6FC0091331F /* TestFController.m */,
);
path = "用代理配置数据源(以相册为例)";
sourceTree = "<group>";
};
3B561BDD0EE4EB2318C37D22 /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -738,6 +751,7 @@
23CC34D722DC252C0037018B /* MainController.m in Sources */,
23CC34F622DC593F0037018B /* TestEController.m in Sources */,
23C1F89422D1CB2200793CAA /* YBIBToolViewHandler.m in Sources */,
23FF103622F6B6FC0091331F /* TestFController.m in Sources */,
23ABA2AF22D0BAB700535F6A /* YBIBCopywriter.m in Sources */,
23C282F222D5F4540084E9E6 /* YBIBVideoCell.m in Sources */,
23ABA2A922D0BAB700535F6A /* YBIBToastView.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,4 @@ - (void)selectedIndex:(NSInteger)index {

}


@end
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
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
3 changes: 2 additions & 1 deletion YBImageBrowserDemo/MainController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import "TestCController.h"
#import "TestDController.h"
#import "TestEController.h"
#import "TestFController.h"

@interface MainController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
Expand All @@ -26,7 +27,7 @@ @implementation MainController {
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"YBImageBrowser";
_controllers = @[TestAController.self, TestBController.self, TestCController.self, TestDController.self, TestEController.self];
_controllers = @[TestAController.self, TestBController.self, TestCController.self, TestDController.self, TestFController.self, TestEController.self];
[self.view addSubview:self.tableView];
}

Expand Down

0 comments on commit 9ab503d

Please sign in to comment.