Skip to content

Commit 372ad67

Browse files
孟遥遥孟遥遥
孟遥遥
authored and
孟遥遥
committed
相册权限配置
1 parent 8a52e12 commit 372ad67

File tree

7 files changed

+18
-4
lines changed

7 files changed

+18
-4
lines changed

CocoaAsyncSocket_TCP/ChatModel/ChatAlbumModel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ChatAlbumModel.h
33
// CocoaAsyncSocket_TCP
44
//
5-
// Created by 孟遥遥 on 2017/5/20.
5+
// Created by 孟遥 on 2017/5/20.
66
// Copyright © 2017年 mengyao. All rights reserved.
77
//
88

@@ -26,4 +26,5 @@
2626
@property (nonatomic, strong) UIImage *videoCoverImg;
2727
//视频时长
2828
@property (nonatomic, copy) NSString *videoDuration;
29+
2930
@end

CocoaAsyncSocket_TCP/ChatModel/ChatAlbumModel.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
// ChatAlbumModel.m
33
// CocoaAsyncSocket_TCP
44
//
5-
// Created by 孟遥遥 on 2017/5/20.
5+
// Created by 孟遥 on 2017/5/20.
66
// Copyright © 2017年 mengyao. All rights reserved.
77
//
88

99
#import "ChatAlbumModel.h"
1010

1111
@implementation ChatAlbumModel
1212

13+
1314
@end

CocoaAsyncSocket_TCP/Comon/Category/UIImage+photoPicker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
typedef void(^photoPickerImagesCallback)(NSArray<ChatAlbumModel *> *images);
1414

1515
//返回视频存储的位置
16-
typedef void(^videoPathCallback)(ChatAlbumModel *);
16+
typedef void(^videoPathCallback)(ChatAlbumModel *videoModel);
1717

1818

1919
@interface UIImage (photoPicker)

CocoaAsyncSocket_TCP/Controller/ChatViewController.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ - (ChatKeyboard *)customKeyboard
3838
{
3939
if (!_customKeyboard) {
4040
_customKeyboard = [[ChatKeyboard alloc]init];
41+
//传入当前控制器 ,方便打开相册(如放到控制器 , 后期的逻辑过多,控制器会更加臃肿)
42+
_customKeyboard.target = self;
4143
}
4244
return _customKeyboard;
4345
}

CocoaAsyncSocket_TCP/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
<string>LaunchScreen</string>
2525
<key>UIMainStoryboardFile</key>
2626
<string>Main</string>
27+
<key>NSPhotoLibraryUsageDescription</key>
28+
<string>是否允许打开相册</string>
2729
<key>UIRequiredDeviceCapabilities</key>
2830
<array>
2931
<string>armv7</string>

CocoaAsyncSocket_TCP/View/KeyBoard/ChatKeyboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//仅声明,消除警告
1414
- (void)systemKeyboardWillShow:(NSNotification *)note;
1515

16-
16+
@property (nonatomic, strong) UIViewController *target;
1717

1818

1919

CocoaAsyncSocket_TCP/View/KeyBoard/ChatKeyboard.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#import "ChatKeyboard.h"
1111
#import "ChatRecordTool.h"
12+
#import "UIImage+photoPicker.h"
1213

1314
@interface ChatHandleButton : UIButton
1415
@end
@@ -515,6 +516,10 @@ - (void)handleButtonClick:(ChatHandleButton *)button
515516
switch (button.tag - 9999) {
516517
case 0:
517518
{
519+
// 这里用到了TZImagerPicker 相册选择器 写得挺好的 ,我对它进行了封装和修改了里面一些代码 。 后期有时间会自己写一个相册的选择器
520+
[UIImage openPhotoPickerGetImages:^(NSArray<ChatAlbumModel *> *images) {
521+
522+
} target:self.target maxCount:9];
518523
NSLog(@"-------------点击了相册");
519524
}
520525
break;
@@ -525,6 +530,9 @@ - (void)handleButtonClick:(ChatHandleButton *)button
525530
break;
526531
case 2:
527532
{
533+
[UIImage openPhotoPickerGetVideo:^(ChatAlbumModel *videoModel) {
534+
535+
} target:self.target cacheDirectory:nil];
528536
NSLog(@"-------------点击了视频相册");
529537
}
530538
break;

0 commit comments

Comments
 (0)