Skip to content

Commit 7000343

Browse files
authored
Merge pull request banchichen#1526 from qiaoxiyang/master
新增iOS14下可以添加访问更多照片
2 parents c5c4b0d + f981b65 commit 7000343

File tree

13 files changed

+245
-38
lines changed

13 files changed

+245
-38
lines changed

TZImagePickerController.xcodeproj/project.pbxproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
570A348C26D7275C000EEF2E /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570A348B26D7275C000EEF2E /* Photos.framework */; };
11+
570A348E26D72762000EEF2E /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570A348D26D72762000EEF2E /* PhotosUI.framework */; };
12+
570A349026D72768000EEF2E /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570A348F26D72768000EEF2E /* PhotosUI.framework */; };
13+
57DD378A26D61592005090FF /* TZAuthLimitedFooterTipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 57DD378926D61592005090FF /* TZAuthLimitedFooterTipView.m */; };
14+
57DD378E26D619C9005090FF /* TZAuthLimitedFooterTipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 57DD378926D61592005090FF /* TZAuthLimitedFooterTipView.m */; };
1015
6D32B9BD1CD83640005CE1E0 /* LxGridViewFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D32B9BC1CD83640005CE1E0 /* LxGridViewFlowLayout.m */; };
1116
6D4608311DFFC60D004FB009 /* TZGifPhotoPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D4608301DFFC60D004FB009 /* TZGifPhotoPreviewController.m */; };
1217
6D5358CD1D64600F00928CC6 /* NSBundle+TZImagePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D5358CC1D64600F00928CC6 /* NSBundle+TZImagePicker.m */; };
@@ -117,6 +122,11 @@
117122
/* End PBXCopyFilesBuildPhase section */
118123

119124
/* Begin PBXFileReference section */
125+
570A348B26D7275C000EEF2E /* Photos.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Photos.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Photos.framework; sourceTree = DEVELOPER_DIR; };
126+
570A348D26D72762000EEF2E /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/iOSSupport/System/Library/Frameworks/PhotosUI.framework; sourceTree = DEVELOPER_DIR; };
127+
570A348F26D72768000EEF2E /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = System/Library/Frameworks/PhotosUI.framework; sourceTree = SDKROOT; };
128+
57DD378826D61592005090FF /* TZAuthLimitedFooterTipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TZAuthLimitedFooterTipView.h; sourceTree = "<group>"; };
129+
57DD378926D61592005090FF /* TZAuthLimitedFooterTipView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TZAuthLimitedFooterTipView.m; sourceTree = "<group>"; };
120130
6D12FC191D66B71E00182C44 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = "<group>"; };
121131
6D12FC1A1D66B71E00182C44 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchScreen.strings"; sourceTree = "<group>"; };
122132
6D32B9BB1CD83640005CE1E0 /* LxGridViewFlowLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LxGridViewFlowLayout.h; sourceTree = "<group>"; };
@@ -197,6 +207,7 @@
197207
isa = PBXFrameworksBuildPhase;
198208
buildActionMask = 2147483647;
199209
files = (
210+
570A349026D72768000EEF2E /* PhotosUI.framework in Frameworks */,
200211
903996931F447604005E77C2 /* Photos.framework in Frameworks */,
201212
);
202213
runOnlyForDeploymentPostprocessing = 0;
@@ -219,6 +230,8 @@
219230
isa = PBXFrameworksBuildPhase;
220231
buildActionMask = 2147483647;
221232
files = (
233+
570A348E26D72762000EEF2E /* PhotosUI.framework in Frameworks */,
234+
570A348C26D7275C000EEF2E /* Photos.framework in Frameworks */,
222235
);
223236
runOnlyForDeploymentPostprocessing = 0;
224237
};
@@ -334,6 +347,8 @@
334347
B662C36E2662914D006A672A /* TZVideoEditedPreviewController.m */,
335348
6DD050291DF659ED0057C78D /* TZProgressView.h */,
336349
6DD0502A1DF659ED0057C78D /* TZProgressView.m */,
350+
57DD378826D61592005090FF /* TZAuthLimitedFooterTipView.h */,
351+
57DD378926D61592005090FF /* TZAuthLimitedFooterTipView.m */,
337352
90CE84AC1C3A89EF003D0779 /* TZImageManager.h */,
338353
90CE84AD1C3A89EF003D0779 /* TZImageManager.m */,
339354
901CC3F821CB757500C55443 /* TZImageRequestOperation.h */,
@@ -365,6 +380,9 @@
365380
903996911F447603005E77C2 /* Frameworks */ = {
366381
isa = PBXGroup;
367382
children = (
383+
570A348D26D72762000EEF2E /* PhotosUI.framework */,
384+
570A348F26D72768000EEF2E /* PhotosUI.framework */,
385+
570A348B26D7275C000EEF2E /* Photos.framework */,
368386
903996941F447609005E77C2 /* AssetsLibrary.framework */,
369387
903996921F447604005E77C2 /* Photos.framework */,
370388
);
@@ -593,6 +611,7 @@
593611
900EF0021C2BD7E400EA709B /* TZAssetCell.m in Sources */,
594612
6DD0502B1DF659ED0057C78D /* TZProgressView.m in Sources */,
595613
6D32B9BD1CD83640005CE1E0 /* LxGridViewFlowLayout.m in Sources */,
614+
57DD378A26D61592005090FF /* TZAuthLimitedFooterTipView.m in Sources */,
596615
6D4608311DFFC60D004FB009 /* TZGifPhotoPreviewController.m in Sources */,
597616
900EF0161C2C134900EA709B /* TZPhotoPreviewCell.m in Sources */,
598617
900E65871C2BB8D5003D9A9E /* ViewController.m in Sources */,
@@ -633,6 +652,7 @@
633652
isa = PBXSourcesBuildPhase;
634653
buildActionMask = 2147483647;
635654
files = (
655+
57DD378E26D619C9005090FF /* TZAuthLimitedFooterTipView.m in Sources */,
636656
B662C37326629179006A672A /* TZVideoEditedPreviewController.m in Sources */,
637657
B6977B0A265FDB280028BA31 /* TZVideoCropController.m in Sources */,
638658
901CC3FB21CB757500C55443 /* TZImageRequestOperation.m in Sources */,

TZImagePickerController/Base.lproj/LaunchScreen.storyboard

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="14F1509" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
34
<dependencies>
45
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
7+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
68
</dependencies>
79
<scenes>
810
<!--View Controller-->
@@ -14,9 +16,9 @@
1416
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
1517
</layoutGuides>
1618
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
17-
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
19+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
1820
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19-
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
21+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2022
</view>
2123
</viewController>
2224
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>

TZImagePickerController/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
<string>1</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
25+
<key>PHPhotoLibraryPreventAutomaticLimitedAccessAlert</key>
26+
<true/>
2527
<key>NSCameraUsageDescription</key>
2628
<string>访问相机以拍照</string>
2729
<key>NSLocationUsageDescription</key>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// TZAuthLimitedFooterTipView.h
3+
// TZImagePickerController
4+
//
5+
// Created by qiaoxy on 2021/8/24.
6+
//
7+
8+
#import <UIKit/UIKit.h>
9+
10+
NS_ASSUME_NONNULL_BEGIN
11+
12+
@interface TZAuthLimitedFooterTipView : UIView
13+
14+
@end
15+
16+
NS_ASSUME_NONNULL_END
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
//
2+
// TZAuthLimitedFooterTipView.m
3+
// TZImagePickerController
4+
//
5+
// Created by qiaoxy on 2021/8/24.
6+
//
7+
8+
#import "TZAuthLimitedFooterTipView.h"
9+
#import "TZImagePickerController.h"
10+
11+
@interface TZAuthLimitedFooterTipView()
12+
@property (nonatomic,strong) UIImageView *tipImgView;
13+
@property (nonatomic,strong) UILabel *tipLable;
14+
@property (nonatomic,strong) UIImageView *detailImgView;
15+
@end
16+
17+
@implementation TZAuthLimitedFooterTipView
18+
19+
- (instancetype)init {
20+
self = [super init];
21+
if (self) {
22+
[self initSubViews];
23+
}
24+
return self;
25+
}
26+
27+
- (instancetype)initWithFrame:(CGRect)frame {
28+
self = [super initWithFrame:frame];
29+
if (self) {
30+
[self initSubViews];
31+
}
32+
return self;
33+
}
34+
35+
- (void)initSubViews {
36+
[self addSubview:self.tipImgView];
37+
[self addSubview:self.tipLable];
38+
[self addSubview:self.detailImgView];
39+
CGFloat margin = 15;
40+
CGFloat tipImgViewWH = 20;
41+
CGFloat detailImgViewWH = 12;
42+
CGFloat screenW = [UIScreen mainScreen].bounds.size.width;
43+
44+
self.tipImgView.frame = CGRectMake(margin, 0, tipImgViewWH, tipImgViewWH);
45+
self.detailImgView.frame = CGRectMake(screenW - margin - detailImgViewWH, 0, detailImgViewWH, detailImgViewWH);
46+
47+
CGFloat tipLabelX = CGRectGetMaxX(self.tipImgView.frame) + 10;
48+
CGFloat tipLabelW = screenW - tipLabelX - detailImgViewWH - margin - 4;
49+
self.tipLable.frame = CGRectMake(tipLabelX, 0, tipLabelW, self.bounds.size.height);
50+
51+
self.tipImgView.center = CGPointMake(self.tipImgView.center.x, self.tipLable.center.y);
52+
self.detailImgView.center = CGPointMake(self.detailImgView.center.x, self.tipLable.center.y);
53+
}
54+
55+
#pragma mark - Getter
56+
57+
- (UIImageView *)tipImgView {
58+
if (!_tipImgView) {
59+
_tipImgView = [[UIImageView alloc] init];
60+
_tipImgView.contentMode = UIViewContentModeScaleAspectFit;
61+
_tipImgView.image = [UIImage tz_imageNamedFromMyBundle:@"tip"];
62+
}
63+
return _tipImgView;
64+
}
65+
66+
- (UILabel *)tipLable {
67+
if (!_tipLable) {
68+
_tipLable = [[UILabel alloc] init];
69+
NSString *appName = [TZCommonTools tz_getAppName];
70+
_tipLable.text = [NSString stringWithFormat:@"你已设置%@只能访问相册部分照片,建议允许访问「所有照片」",appName];
71+
_tipLable.numberOfLines = 0;
72+
_tipLable.font = [UIFont systemFontOfSize:14];
73+
_tipLable.textColor = [UIColor colorWithRed:0.40 green:0.40 blue:0.40 alpha:1.0];
74+
}
75+
return _tipLable;
76+
}
77+
78+
- (UIImageView *)detailImgView {
79+
if (!_detailImgView) {
80+
_detailImgView = [[UIImageView alloc] init];
81+
_detailImgView.contentMode = UIViewContentModeScaleAspectFit;
82+
_detailImgView.image = [UIImage tz_imageNamedFromMyBundle:@"right_arrow"];
83+
}
84+
return _detailImgView;
85+
}
86+
87+
@end

TZImagePickerController/TZImagePickerController/TZImageManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
/// Return YES if Authorized 返回YES如果得到了授权
5050
- (BOOL)authorizationStatusAuthorized;
5151
- (void)requestAuthorizationWithCompletion:(void (^)(void))completion;
52+
- (BOOL)isPHAuthorizationStatusLimited;
5253

5354
/// Get Album 获得相册/相册数组
5455
- (void)getCameraRollAlbumWithFetchAssets:(BOOL)needFetchAssets completion:(void (^)(TZAlbumModel *model))completion;

TZImagePickerController/TZImagePickerController/TZImageManager.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ - (void)configTZScreenWidth {
6464
}
6565
}
6666

67+
- (BOOL)isPHAuthorizationStatusLimited {
68+
if (@available(iOS 14,*)) {
69+
NSInteger status = [PHPhotoLibrary authorizationStatusForAccessLevel:PHAccessLevelReadWrite];
70+
if (status == PHAuthorizationStatusLimited) {
71+
return YES;
72+
}
73+
}
74+
return NO;
75+
}
76+
6777
/// Return YES if Authorized 返回YES如果得到了授权
6878
- (BOOL)authorizationStatusAuthorized {
6979
if (self.isPreviewNetworkImage) {

0 commit comments

Comments
 (0)