Skip to content

Commit

Permalink
完善LBPhotoBrowser
Browse files Browse the repository at this point in the history
  • Loading branch information
tianliangyihou committed Mar 1, 2018
1 parent d7363d8 commit 3faacde
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
test.xcworkspace/xcuserdata/dengweihao.xcuserdatad/UserInterfaceState.xcuserstate
test.xcworkspace/xcuserdata/dengweihao.xcuserdatad/UserInterfaceState.xcuserstate
test.xcworkspace/xcuserdata/dengweihao.xcuserdatad/UserInterfaceState.xcuserstate
.DS_Store
test.xcworkspace/xcuserdata/dengweihao.xcuserdatad/UserInterfaceState.xcuserstate
138 changes: 138 additions & 0 deletions LBPhotoBrowser.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#
# Be sure to run `pod spec lint LBPhotoBrowser.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#

Pod::Spec.new do |s|

# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# These will help people to find your library, and whilst it
# can feel like a chore to fill in it's definitely to your advantage. The
# summary should be tweet-length, and the description more in depth.
#

s.name = "LBPhotoBrowser"
s.version = "2.2.1"
s.summary = "a photo browser for iOS."

# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = <<-DESC
a photo browser High imitation WeChat
DESC

s.homepage = "https://github.com/tianliangyihou/LBPhotoBrowser"
# s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"


# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Licensing your code is important. See http://choosealicense.com for more info.
# CocoaPods will detect a license file if there is a named LICENSE*
# Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
#

s.license = "MIT"
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }


# ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the authors of the library, with email addresses. Email addresses
# of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
# accepts just a name if you'd rather not provide an email address.
#
# Specify a social_media_url where others can refer to, for example a twitter
# profile URL.
#

s.author = { "llb" => "1422295521@qq.com" }
# Or just: s.author = "llb"
# s.authors = { "llb" => "1422295521@qq.com" }
# s.social_media_url = "http://twitter.com/llb"

# ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If this Pod runs only on iOS or OS X, then specify the platform and
# the deployment target. You can optionally include the target after the platform.
#

s.platform = :ios
s.platform = :ios, "6.0"

# When using multiple platforms
# s.ios.deployment_target = "5.0"
# s.osx.deployment_target = "10.7"
# s.watchos.deployment_target = "2.0"
# s.tvos.deployment_target = "9.0"


# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the location from where the source should be retrieved.
# Supports git, hg, bzr, svn and HTTP.
#

s.source = { :git => "https://github.com/tianliangyihou/LBPhotoBrowser.git", :tag => "2.2.1" }


# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# CocoaPods is smart about how it includes source code. For source files
# giving a folder will include any swift, h, m, mm, c & cpp files.
# For header files it will include any header in the folder.
# Not including the public_header_files will make all headers public.
#

s.source_files = "Classes", "test/LBPhotoBrowser/*.{h,m}"
s.exclude_files = "Classes/Exclude"

# s.public_header_files = "Classes/**/*.h"


# ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# A list of resources included with the Pod. These are copied into the
# target bundle with a build phase script. Anything else will be cleaned.
# You can preserve files from being cleaned, please don't preserve
# non-essential files like tests, examples and documentation.
#

s.resource = "test/LBPhotoBrowser/LBLoadError.jpg"
s.resource = "test/LBPhotoBrowser/LBLoading.png"
# s.resources = "Resources/*.png"

# s.preserve_paths = "FilesToSave", "MoreFilesToSave"


# ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Link your library with frameworks, or libraries. Libraries do not include
# the lib prefix of their name.
#

# s.framework = "SomeFramework"
# s.frameworks = "SomeFramework", "AnotherFramework"

# s.library = "iconv"
# s.libraries = "iconv", "xml2"


# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If your library depends on compiler flags you can set them in the xcconfig hash
# where they will only apply to your library. If you depend on other Podspecs
# you can include multiple dependencies to ensure it works.

s.requires_arc = true

# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
s.dependency "SDWebImage"
end
19 changes: 8 additions & 11 deletions test.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
26341D431FF2402B001DBE92 /* LBCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 26341D421FF2402B001DBE92 /* LBCell.m */; };
26341D471FF244D4001DBE92 /* LBModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 26341D461FF244D4001DBE92 /* LBModel.m */; };
26341D5D1FF4955A001DBE92 /* placehold.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = 26341D5C1FF49559001DBE92 /* placehold.jpeg */; };
2639F3B02047A3310099186E /* LBPhotoBrowser.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 2639F3AF2047A3310099186E /* LBPhotoBrowser.bundle */; };
2657DB661E77BCDD00F324C3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2657DB651E77BCDD00F324C3 /* main.m */; };
2657DB691E77BCDD00F324C3 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2657DB681E77BCDD00F324C3 /* AppDelegate.m */; };
2657DB6C1E77BCDD00F324C3 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2657DB6B1E77BCDD00F324C3 /* ViewController.m */; };
2657DB6F1E77BCDD00F324C3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2657DB6D1E77BCDD00F324C3 /* Main.storyboard */; };
2657DB711E77BCDD00F324C3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2657DB701E77BCDD00F324C3 /* Assets.xcassets */; };
2657DB741E77BCDD00F324C3 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2657DB721E77BCDD00F324C3 /* LaunchScreen.storyboard */; };
267AD8911F5E3B3A00DC6D9F /* LBLoadError.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 267AD87D1F5E3B3A00DC6D9F /* LBLoadError.jpg */; };
267AD8921F5E3B3A00DC6D9F /* LBLoading.png in Resources */ = {isa = PBXBuildFile; fileRef = 267AD87E1F5E3B3A00DC6D9F /* LBLoading.png */; };
267AD8931F5E3B3A00DC6D9F /* LBLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 267AD8801F5E3B3A00DC6D9F /* LBLoadingView.m */; };
267AD8941F5E3B3A00DC6D9F /* LBOptionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 267AD8821F5E3B3A00DC6D9F /* LBOptionView.m */; };
267AD8951F5E3B3A00DC6D9F /* LBPhotoBrowserConst.m in Sources */ = {isa = PBXBuildFile; fileRef = 267AD8841F5E3B3A00DC6D9F /* LBPhotoBrowserConst.m */; };
Expand Down Expand Up @@ -54,6 +53,7 @@
26341D451FF244D4001DBE92 /* LBModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LBModel.h; sourceTree = "<group>"; };
26341D461FF244D4001DBE92 /* LBModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LBModel.m; sourceTree = "<group>"; };
26341D5C1FF49559001DBE92 /* placehold.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = placehold.jpeg; sourceTree = "<group>"; };
2639F3AF2047A3310099186E /* LBPhotoBrowser.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = LBPhotoBrowser.bundle; sourceTree = "<group>"; };
2657DB611E77BCDD00F324C3 /* test.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = test.app; sourceTree = BUILT_PRODUCTS_DIR; };
2657DB651E77BCDD00F324C3 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
2657DB671E77BCDD00F324C3 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
Expand All @@ -64,8 +64,6 @@
2657DB701E77BCDD00F324C3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2657DB731E77BCDD00F324C3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
2657DB751E77BCDD00F324C3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
267AD87D1F5E3B3A00DC6D9F /* LBLoadError.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = LBLoadError.jpg; sourceTree = "<group>"; };
267AD87E1F5E3B3A00DC6D9F /* LBLoading.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = LBLoading.png; sourceTree = "<group>"; };
267AD87F1F5E3B3A00DC6D9F /* LBLoadingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LBLoadingView.h; sourceTree = "<group>"; };
267AD8801F5E3B3A00DC6D9F /* LBLoadingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LBLoadingView.m; sourceTree = "<group>"; };
267AD8811F5E3B3A00DC6D9F /* LBOptionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LBOptionView.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -224,8 +222,7 @@
267AD87C1F5E3B3A00DC6D9F /* LBPhotoBrowser */ = {
isa = PBXGroup;
children = (
267AD87D1F5E3B3A00DC6D9F /* LBLoadError.jpg */,
267AD87E1F5E3B3A00DC6D9F /* LBLoading.png */,
2639F3AF2047A3310099186E /* LBPhotoBrowser.bundle */,
267AD87F1F5E3B3A00DC6D9F /* LBLoadingView.h */,
267AD8801F5E3B3A00DC6D9F /* LBLoadingView.m */,
267AD8811F5E3B3A00DC6D9F /* LBOptionView.h */,
Expand Down Expand Up @@ -332,6 +329,7 @@
TargetAttributes = {
2657DB601E77BCDD00F324C3 = {
CreatedOnToolsVersion = 8.0;
DevelopmentTeam = M974WD5VWM;
ProvisioningStyle = Manual;
SystemCapabilities = {
com.apple.SafariKeychain = {
Expand Down Expand Up @@ -364,11 +362,10 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
267AD8921F5E3B3A00DC6D9F /* LBLoading.png in Resources */,
2639F3B02047A3310099186E /* LBPhotoBrowser.bundle in Resources */,
267D19F52015833700B87BE0 /* LBTestVC.xib in Resources */,
2657DB741E77BCDD00F324C3 /* LaunchScreen.storyboard in Resources */,
2657DB711E77BCDD00F324C3 /* Assets.xcassets in Resources */,
267AD8911F5E3B3A00DC6D9F /* LBLoadError.jpg in Resources */,
26341D5D1FF4955A001DBE92 /* placehold.jpeg in Resources */,
2657DB6F1E77BCDD00F324C3 /* Main.storyboard in Resources */,
);
Expand Down Expand Up @@ -575,14 +572,14 @@
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = M974WD5VWM;
INFOPLIST_FILE = test/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.vcyber.test;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
PROVISIONING_PROFILE = "44290f65-14f3-4c5a-bce8-f7896707fea4";
PROVISIONING_PROFILE_SPECIFIER = CYW_ALL_APP_Development;
};
name = Debug;
};
Expand Down
4 changes: 3 additions & 1 deletion test/Class/Base/Controller/LBTestVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ - (void)viewDidLoad {
*/
NSString *urlString = @"http://img.zcool.cn/community/0132f455a6d04432f8758bed5f25a9.gif";
NSURL *url = [NSURL URLWithString:urlString];
[_testImageView1 sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"LBLoadError.jpg"]];

NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[LBTestVC class]] pathForResource:@"LBPhotoBrowser" ofType:@"bundle"]];
[_testImageView1 sd_setImageWithURL:url placeholderImage:[UIImage imageWithContentsOfFile:[bundle pathForResource:@"LBLoadError.png" ofType:nil]]];

__weak typeof(self) wself = self;
[[SDWebImageManager sharedManager] loadImageWithURL:url options:SDWebImageRetryFailed progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
Expand Down
2 changes: 0 additions & 2 deletions test/Class/style3/LBStyle3VC.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[items addObject:item];
}
[LBPhotoBrowserManager.defaultManager showImageWithWebItems:items selectedIndex:tag fromImageViewSuperView:wcell.contentView].lowGifMemory = YES;

[[[LBPhotoBrowserManager.defaultManager addLongPressShowTitles:@[@"保存",@"识别二维码",@"取消"]] addTitleClickCallbackBlock:^(UIImage *image, NSIndexPath *indexPath, NSString *title) {
LBPhotoBrowserLog(@"%@",title);
}]addPhotoBrowserWillDismissBlock:^{
Expand All @@ -66,7 +65,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[[LBPhotoBrowserManager defaultManager] addPlaceholdImageCallBackBlock:^UIImage *(NSIndexPath *indexPath) {
return [UIImage imageNamed:@"placehold.jpeg"];
}];

}];
return cell;
}
Expand Down
Binary file removed test/LBPhotoBrowser/LBLoadError.jpg
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
8 changes: 7 additions & 1 deletion test/LBPhotoBrowser/LBPhotoBrowserManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
// 展示图片使用collectionView来提高效率
@property (nonatomic , weak)UICollectionView *currentCollectionView;

//当图片加载出现错误时候显示的图片 default is [UIImage imageNamed:@"LBLoadError.jpg"]
//当图片加载出现错误时候显示的图片 default is [UIImage imageNamed:@"LBLoadError.png"]
//如果LBLoadError.png这张图片不满意 可以修改这个属性替换
@property (nonatomic , strong)UIImage *errorImage;

// 每张正在加载的图片的占位图
Expand All @@ -96,6 +97,11 @@
*/
@property (nonatomic , assign)BOOL needPreloading;

/**
含有图片的bundle
*/
@property (nonatomic , strong, readonly)NSBundle *lb_resourceBundle;

/**
返回当前的一个单例(不完全单利)
*/
Expand Down
5 changes: 4 additions & 1 deletion test/LBPhotoBrowser/LBPhotoBrowserManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ @implementation LBPhotoBrowserManager

@synthesize linkageInfo = _linkageInfo;

@synthesize lb_resourceBundle = _lb_resourceBundle;

- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
Expand Down Expand Up @@ -175,7 +177,8 @@ - (instancetype)init
{
self = [super init];
if (self) {
self.errorImage = [UIImage imageNamed:@"LBLoadError.jpg"];
_lb_resourceBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[LBPhotoBrowserView class]] pathForResource:@"LBPhotoBrowser" ofType:@"bundle"]];
_errorImage = [UIImage imageWithContentsOfFile:[_lb_resourceBundle pathForResource:@"LBLoadError.png" ofType:nil]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(photoBrowserWillDismiss) name:LBImageViewWillDismissNot object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(photoBrowserDidDismiss) name:LBImageViewDidDismissNot object:nil];
_requestQueue = [[NSOperationQueue alloc] init];
Expand Down
4 changes: 2 additions & 2 deletions test/LBPhotoBrowser/LBZoomScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ - (UIImage *)getPlaceholdImageForModel:(LBScrollViewStatusModel *)model {
if (mgr.placeholdImageCallBackBlock) {
placeholdImage = mgr.placeholdImageCallBackBlock([NSIndexPath indexPathForItem:model.index inSection:0]);
if (!placeholdImage) {
placeholdImage =[UIImage imageNamed:@"LBLoading.png"];
placeholdImage = [UIImage imageWithContentsOfFile:[mgr.lb_resourceBundle pathForResource:@"LBLoading.png" ofType:nil]];
}
}else {
placeholdImage =[UIImage imageNamed:@"LBLoading.png"];
placeholdImage = [UIImage imageWithContentsOfFile:[mgr.lb_resourceBundle pathForResource:@"LBLoading.png" ofType:nil]];
}
return placeholdImage;
}
Expand Down

0 comments on commit 3faacde

Please sign in to comment.