This commit is contained in:
lianxiang
2018-09-23 01:30:29 +08:00
parent db1740e72b
commit 3508cab25e
80 changed files with 3687 additions and 127 deletions
@@ -1,9 +1,17 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "app_logo@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "bg_moreandmore_red@2x.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 818 B

@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "img_camera@2x.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "img_holder@2x.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

+1 -2
View File
@@ -228,11 +228,10 @@
if (jsonString == nil) {
return nil;
}
//⚠️ 13.2.0库编码采用 isoLatin1
//⚠️
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
//NSData *jsonData = [jsonString dataUsingEncoding:NSISOLatin1StringEncoding];
NSError *err;
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData
options:NSJSONReadingMutableContainers
+6 -1
View File
@@ -22,10 +22,15 @@ typedef void (^responseBlock)(NSDictionary *responseDict, NSDictionary *response
// 测试题 , 登录 body 传参
+(void)userbodyRequest:(NSString *)url params:(NSDictionary *)param completionHandler:(nullable void (^)(NSURLResponse *response, NSDictionary *resDic, NSError * _Nullable error))completionHandler;
//上传图片
//上传图片 1张
+(void)uploadImage:(NSString *)url
imgData:(NSData *)imgData
parms:(NSDictionary *)parms
responseBlock:(responseBlock)block;
+(void)uploadImage:(NSString *)url
imageNames:(NSArray *)imageNames
parms:(NSDictionary *)parms
responseBlock:(responseBlock)block;
@end
+53 -4
View File
@@ -10,7 +10,7 @@
#import "AFNetworking.h"
#import "GiGaServerConfig.h"
#import "GiGaUserDefault.h"
#import "GIGaUserFileHelper.h"
@interface GiGaNetManager()
@end
@@ -130,7 +130,7 @@
[task resume];
}
//上传1张
+(void)uploadImage:(NSString *)url
imgData:(NSData *)imgData
parms:(NSDictionary *)parms
@@ -182,6 +182,55 @@
}];
}
//上传多张
+(void)uploadImage:(NSString *)url
imageNames:(NSArray *)imageNames
parms:(NSDictionary *)parms
responseBlock:(responseBlock)block
{
AFHTTPSessionManager*manager=[[AFHTTPSessionManager alloc] init];
manager.responseSerializer=[AFHTTPResponseSerializer serializer];
NSString *token = [GiGaUserDefault getCurentToken];
if (token) {
[manager.requestSerializer setValue:token forHTTPHeaderField:@"token"];
}
NSString *fullurl = [NSString stringWithFormat:@"%@%@",[GiGaServerConfig getMainUrl],url];
[manager POST:fullurl parameters:parms constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
for (NSUInteger i= 0; i < imageNames.count; i ++) {
//上传时使用当前的系统事件作为文件名
// NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
//
// formatter.dateFormat = @"yyyyMMddHHmmss";
//
// NSString *str = [formatter stringFromDate:[NSDate date]];
NSString *fileName = [NSString stringWithFormat:@"%@.png", imageNames[i]];
//服务器上传文件的字段和类型
UIImage *image =[GIGaUserFileHelper getUserFeedbackImag:imageNames[i]] ;
NSData *imgData = UIImagePNGRepresentation(image);
[formData appendPartWithFileData:imgData name:@"file" fileName:fileName mimeType:@"image/png"];
[formData appendPartWithFormData:imgData name:fileName];
}
} progress:^(NSProgress * _Nonnull uploadProgress) {
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
NSLog(@"%@", dict);
NSDictionary *headerFields = [(NSHTTPURLResponse *)task.response allHeaderFields];
if (block) {
block(dict, headerFields, nil);
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSDictionary *headerFields = [(NSHTTPURLResponse *)task.response allHeaderFields];
if (block) {
block(nil, headerFields, error);
}
}];
}
@end
@@ -15,6 +15,13 @@
+ (UIImage *) scaleFromImage: (UIImage *) image toSize: (CGSize) size;
+ (UIImage *)thumbnailWithImageWithoutScale:(UIImage *)image size:(CGSize)asize;
+(void)savaShareImange:(NSString *)fileName image:(UIImage *)image;
+(UIImage *)zipScaleWithImage:(UIImage *)sourceImage;
+(UIImage *)getUserShareImage:(NSString *)imageName;
+(void)delectShareImage:(NSString *)imageName;
+(void)saveUserFeedbackImag:(NSString *)imagename image:(UIImage *)image;
+(UIImage *)getUserFeedbackImag:(NSString *)imageName;
+(void)delectAllfeedimages;
@end
@@ -20,6 +20,33 @@
}
+(void)savaShareImange:(NSString *)fileName image:(UIImage *)image{
NSData*imageData=UIImageJPEGRepresentation(image,1.0f);
NSString *fullPath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:fileName];
[imageData writeToFile:fullPath atomically:YES];
}
+(void)delectShareImage:(NSString *)imageName{
//删除文件夹及文件级内的文件:
NSString *fullPath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:imageName];
NSFileManager *fileManager = [NSFileManager defaultManager];[fileManager removeItemAtPath:fullPath error:nil];
}
+(UIImage *)getUserShareImage:(NSString *)imageName{
NSString*fullpath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:imageName];
UIImage*saveImage=[[UIImage alloc]initWithContentsOfFile:fullpath];
if (!saveImage) {
saveImage = [UIImage imageNamed:@"sharebg_1"];
}
return saveImage;
}
+ (UIImage *)getUserAvatorWith:(NSString *)userId{
if (!userId) {
@@ -81,4 +108,65 @@
return newimage;
}
+(UIImage *)zipScaleWithImage:(UIImage *)sourceImage{
//进行图像尺寸的压缩
CGSize imageSize = sourceImage.size;
//取出要压缩的image尺寸
CGFloat width = imageSize.width;
//图片宽度
CGFloat height = imageSize.height;
//图片高度 //1.宽高大于1280(宽高比不按照2来算,按照1来算)
if (width>1280||height>1280) { if (width>height) { CGFloat scale = height/width; width = 1280; height = width*scale;
}else{ CGFloat scale = width/height;
height = 1280; width = height*scale;
}
//2.宽大于1280高小于1280
}else if(width>1280||height<1280){
CGFloat scale = height/width;
width = 1280;
height = width*scale;
//3.宽小于1280高大于1280
}else if(width<1280||height>1280){
CGFloat scale = width/height; height = 1280; width = height*scale;
//4.宽高都小于1280
}else{
}
//进行尺寸重绘
UIGraphicsBeginImageContext(CGSizeMake(width, height));
[sourceImage drawInRect:CGRectMake(0,0,width,height)]; UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
return newImage;
}
+(void)saveUserFeedbackImag:(NSString *)imagename image:(UIImage *)image
{
NSData*imageData=UIImagePNGRepresentation(image);
NSString *fullPath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:[NSString stringWithFormat:@"gigafeed/%@.png",imagename]];
NSLog(@"fullPath%@",fullPath);
[imageData writeToFile:fullPath atomically:YES];
}
+(UIImage *)getUserFeedbackImag:(NSString *)imageName{
NSString*fullpath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:[NSString stringWithFormat:@"gigafeed/%@.png",imageName]];
UIImage*saveImage=[[UIImage alloc]initWithContentsOfFile:fullpath];
return saveImage;
}
+(void)delectAllfeedimages{
NSString *fullPath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:[NSString stringWithFormat:@"gigafeed/"]];
NSFileManager *fileManager = [NSFileManager defaultManager];[fileManager removeItemAtPath:fullPath error:nil];
}
@end
@@ -0,0 +1,14 @@
//
// SJPhotoAlbumsController.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/22.
// Copyright © 2016年 S.J. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Photos/Photos.h>
@interface SJPhotoAlbumsController : UIViewController
@end
@@ -0,0 +1,135 @@
//
// SJPhotoAlbumsController.m
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/22.
// Copyright © 2016年 S.J. All rights reserved.
//
#import "SJPhotoAlbumsController.h"
#import "SJPhotoPickerMacro.h"
#import "SJPhotoAlbumCell.h"
#import "SJPickPhotoController.h"
#import "SJPhotoPickerManager.h"
#import "SJAlbumModel.h"
@interface SJPhotoAlbumsController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *tableView;
/**
* 相册数组
*/
@property (nonatomic, strong) NSMutableArray *albumArray;
@end
static NSString *ID_SJPhotoAlbumCell = @"sJPhotoAlbumCell";
@implementation SJPhotoAlbumsController
- (void)viewDidLoad {
[super viewDidLoad];
[self setupDatas];
[self setupViews];
SJPickPhotoController *vc = [[SJPickPhotoController alloc] init];
SJAlbumModel *model = [[SJAlbumModel alloc] init];
model = self.albumArray[0];
vc.assetResult = model.assetResult;
[self.navigationController pushViewController:vc animated:NO];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
#pragma mark 数据初始化
- (void)setupDatas {
[[SJPhotoPickerManager shareSJPhotoPickerManager] requestAlbumsWithType:PHAssetCollectionTypeSmartAlbum albumResult:^(NSArray *albumArray) {
self.albumArray = [albumArray mutableCopy];
}];
[self.tableView reloadData];
}
#pragma mark 视图初始化
- (void)setupViews {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:(UIBarButtonItemStylePlain) target:self action:@selector(rightBarBtnAction:)];
// tableView
{
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W,SCREEN_H) style:(UITableViewStyleGrouped)];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.tableView registerClass:[SJPhotoAlbumCell class] forCellReuseIdentifier:ID_SJPhotoAlbumCell];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.tableView];
}
}
#pragma mark- UITableViewDelegate DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.albumArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
SJPhotoAlbumCell *cell = [tableView dequeueReusableCellWithIdentifier:ID_SJPhotoAlbumCell forIndexPath:indexPath];
if (!cell) {
cell = [[SJPhotoAlbumCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:ID_SJPhotoAlbumCell];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
SJAlbumModel *model = self.albumArray[indexPath.row];
cell.title = [NSString stringWithFormat:@"%@%lu",model.title,model.assetResult.count];
[[SJPhotoPickerManager shareSJPhotoPickerManager] requestImageForPHAsset:model.assetResult[0] targetSize:CGSizeMake(55, 55) imageResult:^(UIImage *image) {
cell.img = image;
}];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 55;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 5.0f;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0.01f;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
SJPickPhotoController *vc = [[SJPickPhotoController alloc] init];
SJAlbumModel *model = self.albumArray[indexPath.row];
vc.assetResult = model.assetResult;
vc.title = model.title;
[self.navigationController pushViewController:vc animated:YES];
}
- (void)rightBarBtnAction:(UIBarButtonItem *)sender {
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
@end
@@ -0,0 +1,13 @@
//
// SJPhotoPickerNavController.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/22.
// Copyright © 2016年 S.J. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SJPhotoPickerNavController : UINavigationController
@end
@@ -0,0 +1,38 @@
//
// SJPhotoPickerNavController.m
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/22.
// Copyright © 2016年 S.J. All rights reserved.
//
#import "SJPhotoPickerNavController.h"
#import "SJPhotoAlbumsController.h"
#import "SJPhotoPickerMacro.h"
@interface SJPhotoPickerNavController ()
@end
@implementation SJPhotoPickerNavController
- (void)viewDidLoad {
[super viewDidLoad];
[self.navigationBar setBarTintColor:NAVBAR_CLOOUR];
[self.navigationBar setTintColor:[UIColor whiteColor]];
[self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
SJPhotoAlbumsController *vc = [[SJPhotoAlbumsController alloc] init];
vc.title = @"相册";
[self pushViewController:vc animated:NO];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end
@@ -0,0 +1,16 @@
//
// SJPickPhotoController.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/19.
// Copyright © 2016年 S.J. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Photos/Photos.h>
@interface SJPickPhotoController : UIViewController
@property (nonatomic, strong) PHFetchResult *assetResult;
@end
@@ -0,0 +1,240 @@
// SJPickPhotoController.m
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/19.
// Copyright © 2016年 S.J. All rights reserved.
//
#import "SJPickPhotoController.h"
#import "SJPhotoPicker.h"
#import "SJPhotoPickerMacro.h"
#import "SJPhotoModel.h"
#import "SJPickPhotoCell.h"
#import "SJPhotoPickerToolBar.h"
#import "SJPreviewPhotoController.h"
@interface SJPickPhotoController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,SJPreviewPhotoControllerDelegate>
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) SJPhotoPickerToolBar *toolBar;
/**
* 所有照片
*/
@property (nonatomic, strong) NSMutableArray<SJPhotoModel *> *photoArray;
/**
* 选择的照片
*/
@property (nonatomic, strong) NSMutableArray<SJPhotoModel *> *pickedArray;
@end
static NSString *ID_SJPickPhotoCell = @"sJPickPhotoCell";
@implementation SJPickPhotoController
- (void)viewDidLoad {
[super viewDidLoad];
[self setupDatas];
[self setupViews];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
#pragma mark 数据初始化
- (void)setupDatas {
// photoArray
{
self.photoArray = [NSMutableArray array];
for (PHAsset *asset in self.assetResult) {
SJPhotoModel *model = [[SJPhotoModel alloc] init];
model.asset = asset;
model.inAlbumIndex = self.photoArray.count;
model.pickedIndex = 0;
model.isPicked = NO;
[self.photoArray addObject:model];
}
[self.collectionView reloadData];
}
// pickedArray
{
self.pickedArray = [NSMutableArray array];
}
}
#pragma mark 视图初始化
- (void)setupViews {
self.view.backgroundColor = [UIColor whiteColor];
if (self.title.length == 0) {
self.title = @"所有照片";
}
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:(UIBarButtonItemStylePlain) target:self action:@selector(rightBarBtnAction:)];
// collectionView
{
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.minimumLineSpacing = 5.0f;
layout.minimumInteritemSpacing = 0.0f;
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 5, SCREEN_W, SCREEN_H - 49) collectionViewLayout:layout];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
[self.collectionView registerClass:[SJPickPhotoCell class] forCellWithReuseIdentifier:ID_SJPickPhotoCell];
self.collectionView.backgroundColor = [UIColor whiteColor];
self.collectionView.pagingEnabled = NO;
[self.view addSubview:self.collectionView];
}
// toolBar
{
self.toolBar = [[SJPhotoPickerToolBar alloc] init];
[self.toolBar.leftBtn addTarget:self action:@selector(previewPhotoAction:) forControlEvents:(UIControlEventTouchUpInside)];
[self.toolBar.rightBtn addTarget:self action:@selector(sureBtnAction:) forControlEvents:(UIControlEventTouchUpInside)];
[self.view addSubview:self.toolBar];
}
}
#pragma mark- UICollectionViewDelegate DataSource
#pragma mark-
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.photoArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
SJPickPhotoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID_SJPickPhotoCell forIndexPath:indexPath];
cell.backgroundColor = [UIColor yellowColor];
SJPhotoModel *model = self.photoArray[indexPath.row];
[cell setModel:model];
__weak typeof(cell) weakCell = cell;
cell.pickBtnBlock = ^(SJPhotoModel *curPickModel) {
[self changeCell:weakCell WithModel:curPickModel];
};
return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake(Image_W, Image_W);
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
SJPreviewPhotoController *vc = [[SJPreviewPhotoController alloc] init];
vc.delegate = self;
vc.curIndex = indexPath.row;
vc.previewArray = [self.photoArray mutableCopy];
[self.navigationController pushViewController:vc animated:YES];
}
#pragma mark- 点击事件
#pragma mark-
#pragma mark 预览
- (void)previewPhotoAction:(UIButton *)sender {
if (self.pickedArray.count > 0) {
SJPreviewPhotoController *vc = [[SJPreviewPhotoController alloc] init];
vc.delegate = self;
vc.curIndex = self.pickedArray.count - 1;
vc.previewArray = [self.pickedArray mutableCopy];
[self.navigationController pushViewController:vc animated:YES];
}
}
#pragma mark 取消
- (void)rightBarBtnAction:(UIBarButtonItem *)sender {
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark 确定
- (void)sureBtnAction:(UIButton *)sender {
NSMutableArray *assetArray = [NSMutableArray array];
for (SJPhotoModel *model in self.pickedArray) {
PHAsset *asset = model.asset;
[assetArray addObject:asset];
}
if (assetArray.count > MAXCOUNT) {
GIGA_ShowToast(@"最多6张");
return;
}
SJPhotoPicker *photoPicker = [SJPhotoPicker shareSJPhotoPicker];
photoPicker.photoPickerBlock(assetArray);
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark- 其他方法
#pragma mark-
#pragma mark 通过改变改变model值,改变cell状态
- (void)pickedArrayChangeWithModel:(SJPhotoModel *)model {
NSIndexPath *changedIndexP =[NSIndexPath indexPathForItem:model.inAlbumIndex inSection:0];
SJPickPhotoCell *changedCell = (SJPickPhotoCell *)[self.collectionView cellForItemAtIndexPath:changedIndexP];
[self changeCell:changedCell WithModel:model];
}
- (void)changeCell:(SJPickPhotoCell *)changedCell WithModel:(SJPhotoModel *)changedModel {
if (changedModel.isPicked) {
[changedCell modelChangePickedIndex:self.pickedArray.count + 1];
[self.pickedArray addObject:changedModel];
}
else {
[self.pickedArray removeObject:changedModel];
// 更新剩下选择的图片
for (int i = 0; i < self.pickedArray.count; i ++) {
SJPhotoModel *otherPickedModel = self.pickedArray[i];
if (otherPickedModel.pickedIndex > changedModel.pickedIndex) {
otherPickedModel.pickedIndex -= 1;
NSIndexPath *indexP =[NSIndexPath indexPathForItem:otherPickedModel.inAlbumIndex inSection:0];
SJPickPhotoCell *otherCell = (SJPickPhotoCell *)[self.collectionView cellForItemAtIndexPath:indexP];
[otherCell modelChangePickedIndex:otherPickedModel.pickedIndex];
}
}
// 更新 取消选择的图片
[changedCell modelChangePickedIndex:0];
}
// 更改工具栏状态信息
[self.toolBar changePickedIndex:self.pickedArray.count];
}
@end
@@ -0,0 +1,27 @@
//
// SJPreviewPhotoController.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/19.
// Copyright © 2016年 S.J. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "SJPhotoModel.h"
@protocol SJPreviewPhotoControllerDelegate <NSObject>
- (void)pickedArrayChangeWithModel:(SJPhotoModel *)model;
@end
@interface SJPreviewPhotoController : UIViewController
@property (nonatomic, strong) NSMutableArray *previewArray;
@property (nonatomic, assign) NSInteger curIndex;
@property (nonatomic, strong) id<SJPreviewPhotoControllerDelegate> delegate;
@end
@@ -0,0 +1,215 @@
//
// SJPreviewPhotoController.m
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/19.
// Copyright © 2016年 S.J. All rights reserved.
//
#import "SJPreviewPhotoController.h"
#import <Photos/Photos.h>
#import "SJPhotoPickerNavBar.h"
#import "SJPhotoPickerToolBar.h"
#import "SJPreviewPhotoCell.h"
#import "SJPhotoPicker.h"
@interface SJPreviewPhotoController ()<UICollectionViewDelegate,UICollectionViewDataSource,SJPhotoPickerNavBarDelegate>
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) SJPhotoPickerToolBar *toolBar;
@property (nonatomic, strong) SJPhotoPickerNavBar *navBar;
@property (nonatomic, strong) UIView *backView;
@property (nonatomic, strong) NSMutableArray *pickedArray;
@property (nonatomic, strong) SJPhotoModel *operatingModel;
@end
static NSString *ID_SJPreviewPhotoCell = @"sJPreviewPhotoCell";
@implementation SJPreviewPhotoController
- (void)viewDidLoad {
[super viewDidLoad];
[self setupDatas];
[self setupViews];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:NO];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
#pragma mark 数据初始化
- (void)setupDatas {
self.pickedArray = [NSMutableArray array];
for (SJPhotoModel *model in self.previewArray) {
if (model.isPicked) {
[self.pickedArray addObject:model];
}
}
[self.collectionView reloadData];
}
#pragma mark 视图初始化
- (void)setupViews {
// collectionView
{
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.minimumLineSpacing = 0.0f;
layout.minimumInteritemSpacing = 0.0f;
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, -64, SCREEN_W, SCREEN_H + 64) collectionViewLayout:layout];
self.collectionView.pagingEnabled = YES;
self.collectionView.showsHorizontalScrollIndicator = NO;
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
[self.collectionView registerClass:[SJPreviewPhotoCell class] forCellWithReuseIdentifier:ID_SJPreviewPhotoCell];
self.collectionView.backgroundColor = [UIColor whiteColor];
[self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:self.curIndex inSection:0] atScrollPosition:(UICollectionViewScrollPositionNone) animated:NO];
self.operatingModel = [self.previewArray lastObject];
[self.view addSubview:self.collectionView];
}
// nav
{
self.navBar = [[SJPhotoPickerNavBar alloc] init];
self.navBar.delegate = self;
self.operatingModel = self.previewArray[self.curIndex];
if (self.title.length == 0) {
self.navBar.leftBtnTitle = @"";
}
self.navBar.barTitle = [NSString stringWithFormat:@"%lu/%lu",(unsigned long)self.curIndex + 1,(unsigned long)self.previewArray.count];
if (self.operatingModel.isPicked) {
[self.navBar setRightBtnTitleIndex:self.operatingModel.pickedIndex];
}
[self.view addSubview:self.navBar];
}
// toolBar
{
self.toolBar = [[SJPhotoPickerToolBar alloc] init];
self.toolBar.backgroundColor = [UIColor colorWithRed:220/255.0 green:220/255.0 blue:220/255.0 alpha:0.3];
self.toolBar.rightBtn.backgroundColor = NAVBAR_CLOOUR;
[self.toolBar.rightBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
self.toolBar.leftBtn.hidden = YES;
[self.toolBar.rightBtn addTarget:self action:@selector(sureBtnAction:) forControlEvents:(UIControlEventTouchUpInside)];
[self.view addSubview:self.toolBar];
}
}
#pragma mark- UICollectionViewDelegate DataSource
#pragma mark-
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.previewArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
SJPreviewPhotoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID_SJPreviewPhotoCell forIndexPath:indexPath];
cell.zoomScale = 1.0;
SJPhotoModel *model = self.previewArray[indexPath.item];
cell.asset = model.asset;
cell.singleTapEvent = ^(){
[self.toolBar changeHideState];
[self.navBar changeHideState];
};
return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake(SCREEN_W, SCREEN_H);
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
NSInteger index = (NSInteger)scrollView.contentOffset.x / SCREEN_W;
self.operatingModel = self.previewArray[index];
self.navBar.barTitle = [NSString stringWithFormat:@"%lu/%lu",index + 1,(unsigned long)self.previewArray.count];
[self.navBar setRightBtnTitleIndex:self.operatingModel.pickedIndex];
}
#pragma mark- 点击事件
#pragma mark-
#pragma mark 单选框点击(SJ...NavBarDelegate
- (void)rightBtnAction:(UIButton *)sender {
self.operatingModel.isPicked = !self.operatingModel.isPicked;
// 代理传值
[self.delegate pickedArrayChangeWithModel:self.operatingModel];
if (self.operatingModel.isPicked) {
NSInteger pickedIndex = self.pickedArray.count + 1;
self.operatingModel.pickedIndex = pickedIndex;
[self.pickedArray addObject:self.operatingModel];
[self.navBar setRightBtnTitleIndex:pickedIndex];
}
else {
[self.pickedArray removeObject:self.operatingModel];
self.operatingModel.pickedIndex = 0;
for (int i = 0; i < self.pickedArray.count; i ++) {
SJPhotoModel *model = self.pickedArray[i];
model.pickedIndex = i + 1;
}
[self.navBar setRightBtnTitleIndex:0];
}
}
#pragma mark 确定按钮
- (void)sureBtnAction:(UIButton *)sender {
NSMutableArray *assetArray = [NSMutableArray array];
for (SJPhotoModel *model in self.pickedArray) {
PHAsset *asset = model.asset;
[assetArray addObject:asset];
}
if (assetArray.count > MAXCOUNT) {
GIGA_ShowToast(@"最多6张");
return;
}
SJPhotoPicker *photoPicker = [SJPhotoPicker shareSJPhotoPicker];
photoPicker.photoPickerBlock(assetArray);
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
@end
+34
View File
@@ -0,0 +1,34 @@
//
// SJPhotoPickerMacro.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/17.
// Copyright © 2016年 S.J. All rights reserved.
//
#ifndef SJPhotoPickerMacro_h
#define SJPhotoPickerMacro_h
#define SCREEN_W CGRectGetWidth([UIScreen mainScreen].bounds)
#define SCREEN_H CGRectGetHeight([UIScreen mainScreen].bounds)
#define Image_W (SCREEN_W - 15.0) / 4.0
#define MAXCOUNT 6
#define NAVBAR_CLOOUR [UIColor colorWithRed:131/255.0 green:10/255.0 blue:10/255.0 alpha:1]
/**
* Notification
*/
#define PICKEDARRAY_SJNOTIFY_CHANGE @"SJPhotoPickedArrayChangeNotification" // 选择图片图片数组中数据改变
#import "SJPhotoPickerManager.h"
#endif /* SJPhotoPickerMacro_h */
@@ -0,0 +1,23 @@
//
// SJPhotoPickerManager.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/19.
// Copyright © 2016年 S.J. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Photos/Photos.h>
typedef void(^ImageBlcok)(UIImage *image);
typedef void(^AlbumBlock)(NSArray *albumArray);
@interface SJPhotoPickerManager : NSObject
+ (instancetype)shareSJPhotoPickerManager;
- (void)requestImageForPHAsset:(PHAsset *)asset targetSize:(CGSize)targetSize imageResult:(ImageBlcok)imageBlock;
- (void)requestAlbumsWithType:(PHAssetCollectionType)type albumResult:(AlbumBlock)albumBlock;
@end
@@ -0,0 +1,84 @@
//
// SJPhotoPickerManager.m
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/19.
// Copyright © 2016年 S.J. All rights reserved.
//
#import "SJPhotoPickerManager.h"
#import "SJAlbumModel.h"
@interface SJPhotoPickerManager()
@end
@implementation SJPhotoPickerManager
+ (instancetype)shareSJPhotoPickerManager {
static SJPhotoPickerManager *manager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (!manager) {
manager = [[SJPhotoPickerManager alloc] init];
}
});
return manager;
}
- (void)requestImageForPHAsset:(PHAsset *)asset targetSize:(CGSize)targetSize imageResult:(ImageBlcok)imageBlock {
// 使用PHImageManager从PHAsset中请求图片
PHImageManager *imageManager = [[PHImageManager alloc] init];
PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
options.resizeMode = PHImageRequestOptionsResizeModeExact;
options.networkAccessAllowed = YES;
[imageManager requestImageForAsset:asset targetSize:targetSize contentMode:PHImageContentModeAspectFit options:options resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
if (result) {
imageBlock(result);
}
}];
}
- (void)requestAlbumsWithType:(PHAssetCollectionType)type albumResult:(AlbumBlock)albumBlock {
// 列出所有相册智能相册
PHFetchResult *assetCollectionResult = [PHAssetCollection fetchAssetCollectionsWithType:type subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
NSMutableArray *albumArray = [NSMutableArray array];
// 这时 smartAlbums 中保存的应该是各个智能相册对应的 PHAssetCollection
for (NSInteger i = 0; i < assetCollectionResult.count; i++) {
// 获取一个相册(PHAssetCollection
PHCollection *collection = assetCollectionResult[i];
if ([collection class] == [PHAssetCollection class]) {
PHAssetCollection *assetCollection = (PHAssetCollection *)collection;
PHFetchResult *assetResult = [PHAsset fetchAssetsInAssetCollection:assetCollection options:nil];
if (assetResult.count != 0) {
SJAlbumModel *model = [[SJAlbumModel alloc] init];
model.title = collection.localizedTitle;
model.assetResult = assetResult;
[albumArray addObject:model];
}
}
albumBlock(albumArray);
}
}
@end
+17
View File
@@ -0,0 +1,17 @@
//
// SJAlbumModel.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/22.
// Copyright © 2016年 S.J. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Photos/Photos.h>
@interface SJAlbumModel : NSObject
@property (nonatomic, strong) PHFetchResult *assetResult;
@property (nonatomic, strong) NSString *title;
@end
+13
View File
@@ -0,0 +1,13 @@
//
// SJAlbumModel.m
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/22.
// Copyright © 2016年 S.J. All rights reserved.
//
#import "SJAlbumModel.h"
@implementation SJAlbumModel
@end
+36
View File
@@ -0,0 +1,36 @@
//
// SJPhotoModel.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/19.
// Copyright © 2016年 S.J. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Photos/Photos.h>
@interface SJPhotoModel : NSObject <NSCopying>
/**
* 图片资源
*/
@property (nonatomic, strong) PHAsset *asset;
/**
* 选中的次序起始值为1 , 0表示没被选中
*/
@property (nonatomic, assign) NSInteger pickedIndex;
/**
* 在相册中次序起始值为 0
*/
@property (nonatomic, assign) NSInteger inAlbumIndex;
/**
* 是否选中 YES——选择 NO——取消选择
*/
@property (nonatomic, assign) BOOL isPicked;
@end
+25
View File
@@ -0,0 +1,25 @@
//
// SJPhotoModel.m
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/19.
// Copyright © 2016年 S.J. All rights reserved.
//
#import "SJPhotoModel.h"
@implementation SJPhotoModel
-(id)copyWithZone:(NSZone *)zone {
SJPhotoModel *modelCopy = [[[self class] allocWithZone:zone] init];
modelCopy.asset = self.asset;
modelCopy.pickedIndex = self.pickedIndex;
modelCopy.inAlbumIndex = self.inAlbumIndex;
return modelCopy;
}
@end
+24
View File
@@ -0,0 +1,24 @@
//
// SJPhotoPicker.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/23.
// Copyright © 2016年 S.J. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "SJPhotoPickerManager.h"
typedef void(^SJPhotoPickerBlock)(NSArray <PHAsset *> *assets);
@interface SJPhotoPicker : NSObject
@property (nonatomic, strong) SJPhotoPickerBlock photoPickerBlock;
+ (instancetype)shareSJPhotoPicker;
- (void) showPhotoPickerToController:(UIViewController *)controller pickedAssets:(SJPhotoPickerBlock)photoPickerBlcok;
@end
+71
View File
@@ -0,0 +1,71 @@
//
// SJPhotoPicker.m
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/23.
// Copyright © 2016年 S.J. All rights reserved.
//
#import "SJPhotoPicker.h"
#import "SJPhotoPickerNavController.h"
@implementation SJPhotoPicker
+ (instancetype)shareSJPhotoPicker {
static SJPhotoPicker *photoPicker = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (!photoPicker) {
photoPicker = [[SJPhotoPicker alloc] init];
}
});
return photoPicker;
}
- (void) showPhotoPickerToController:(UIViewController *)controller pickedAssets:(SJPhotoPickerBlock)photoPickerBlcok {
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status){
dispatch_async(dispatch_get_main_queue(), ^{
switch (status) {
case PHAuthorizationStatusNotDetermined:
{
NSLog(@"用户还没有做出选择");
break;
}
case PHAuthorizationStatusAuthorized:
{
NSLog(@"用户允许当前应用访问相册");
SJPhotoPickerNavController *vc = [[SJPhotoPickerNavController alloc] init];
[controller presentViewController:vc animated:YES completion:nil];
self.photoPickerBlock = photoPickerBlcok;
break;
}
case PHAuthorizationStatusDenied:
{
NSLog(@"用户拒绝当前应用访问相册,我们需要提醒用户打开访问开关");
break;
}
case PHAuthorizationStatusRestricted:
{
NSLog(@"家长控制,不允许访问");
break;
}
default:
{
NSLog(@"default");
break;
}
}
});
}];
}
@end
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

+16
View File
@@ -0,0 +1,16 @@
//
// SJPhotoAlbumCell.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/22.
// Copyright © 2016年 S.J. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SJPhotoAlbumCell : UITableViewCell
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) UIImage *img;
@end
+102
View File
@@ -0,0 +1,102 @@
//
// SJPhotoAlbumCell.m
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/22.
// Copyright © 2016年 S.J. All rights reserved.
//
#import "SJPhotoAlbumCell.h"
#import "SJPhotoPickerMacro.h"
@interface SJPhotoAlbumCell()
@property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *underLine;
@end
@implementation SJPhotoAlbumCell
- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self s_setupCellView];
}
return self;
}
- (void)s_setupCellView {
CGFloat X_Padding = 15.0;
self.imgView = [[UIImageView alloc] initWithFrame:CGRectMake(X_Padding, 0, 55, 54)];
self.imgView.backgroundColor= [UIColor blueColor];
[self.contentView addSubview:self.imgView];
self.titleLab = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.imgView.frame) + 15 , 0,SCREEN_W - CGRectGetWidth(self.imgView.frame) - 15 * 2 - 30, 54)];
[self.contentView addSubview:self.titleLab];
self.underLine = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.imgView.frame) + 15 , CGRectGetMaxY(self.titleLab.frame),SCREEN_W - CGRectGetWidth(self.imgView.frame) - 15 * 2, 1)];
self.underLine.backgroundColor = [UIColor colorWithRed:236/255.0 green:236/255.0 blue:236/255.0 alpha:1];
[self.contentView addSubview:self.underLine];
}
- (NSString *)title {
return self.title;
}
- (void)setTitle:(NSString *)title {
self.titleLab.attributedText = [self attributedString:title];
}
- (UIImage *)img {
return self.img;
}
- (void)setImg:(UIImage *)img {
self.imgView.image = img;
}
/**
* 更改字符串的前两个空格之间字符串的颜色
*
* @param txt 要改变颜色的字符床
*
* @return 改变后的字符串
*/
- (NSMutableAttributedString *)attributedString:(NSString *)txt {
// 查找出前两个空格的位置
NSInteger start = 0;
NSInteger end = 0;
NSRange countRange = NSMakeRange(0, 0);
NSString *leftString = @"";
int leftAsciiCode = [leftString characterAtIndex:0]; // 65
NSString *rightString = @"";
int rightAsciiCode = [rightString characterAtIndex:0]; // 65
for (int i = 0 ; i < txt.length; i ++) {
if ([txt characterAtIndex:i] == leftAsciiCode) {
start = i;
}
if([txt characterAtIndex:i] == rightAsciiCode){
end = i;
}
countRange = NSMakeRange(start, end - start + 1);
}
// 改变范围内字符颜色
NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:txt];
[attributeStr addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:countRange];
return attributeStr;
}
@end
@@ -0,0 +1,30 @@
//
// SJPhotoPickerNavBar.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/22.
// Copyright © 2016年 S.J. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol SJPhotoPickerNavBarDelegate <NSObject>
@optional
- (void)leftBtnAction:(UIButton *)sender;
- (void)rightBtnAction:(UIButton *)sender;
@end
@interface SJPhotoPickerNavBar : UIView
@property (nonatomic, strong) id delegate;
@property (nonatomic, assign) NSInteger rightBtnTitleIndex;
@property (nonatomic, strong) NSString *barTitle;
@property (nonatomic, strong) NSString *leftBtnTitle;
- (void)changeHideState;
@end
+145
View File
@@ -0,0 +1,145 @@
//
// SJPhotoPickerNavBar.m
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/22.
// Copyright © 2016年 S.J. All rights reserved.
//
#import "SJPhotoPickerNavBar.h"
#import "SJPhotoPickerMacro.h"
#import "SJPhotoPickerRaidoButton.h"
@interface SJPhotoPickerNavBar()
@property (nonatomic, strong) UIButton *leftBtn;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) SJPhotoPickerRaidoButton *rightBtn;
@property (nonatomic, assign) BOOL barHide;
@end
@implementation SJPhotoPickerNavBar
- (instancetype)init {
self = [super initWithFrame:CGRectMake(0, 0, SCREEN_W, 64)];
if (self) {
[self setupViews];
}
return self;
}
- (void)setupViews {
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
self.barHide = NO;
// leftBtn
{
self.leftBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
self.leftBtn.frame = CGRectMake(0, 20, 70, 44);
[self.leftBtn setTitleColor:[UIColor colorWithWhite:0.5 alpha:0.5] forState:(UIControlStateHighlighted)];
[self.leftBtn setImageEdgeInsets:UIEdgeInsetsMake(0, -5, 0, 0)];
[self.leftBtn setImage:[UIImage imageNamed:@"photopicker_back"] forState:(UIControlStateNormal)];
[self.leftBtn addTarget:self action:@selector(leftBtnAction:) forControlEvents:(UIControlEventTouchUpInside)];
[self addSubview:self.leftBtn];
}
// titleLab
{
self.titleLab = [[UILabel alloc] init];
self.titleLab.font = [UIFont systemFontOfSize:16];
self.titleLab.textColor = [UIColor whiteColor];
self.titleLab.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.titleLab];
}
// rightBtn
{
self.rightBtn = [[SJPhotoPickerRaidoButton alloc] initWithFrame:CGRectMake(SCREEN_W - 35, 31, 20, 20)];
[self.rightBtn addTarget:self action:@selector(rightBtnAction:) forControlEvents:(UIControlEventTouchUpInside)];
[self addSubview:self.rightBtn];
}
}
- (void)setRightBtnTitleIndex:(NSInteger)rightBtnTitleIndex {
_rightBtnTitleIndex = rightBtnTitleIndex;
[self.rightBtn setPickedIndex:rightBtnTitleIndex];
}
- (void)setLeftBtnTitle:(NSString *)leftBtnTitle {
_leftBtnTitle = leftBtnTitle;
CGFloat titleWidth = [self widthWithString:leftBtnTitle textFontSize:16];
self.leftBtn.frame = CGRectMake(10, 20, titleWidth + 20, 44);
[self.leftBtn setTitle:leftBtnTitle forState:(UIControlStateNormal)];
}
- (void)setBarTitle:(NSString *)barTitle {
_barTitle = barTitle;
CGFloat titleWidth = [self widthWithString:barTitle textFontSize:16];
self.titleLab.frame = CGRectMake((SCREEN_W - titleWidth) * 0.5, 20, titleWidth, 44);
self.titleLab.text = barTitle;
}
- (void)leftBtnAction:(UIButton *)sender {
UIViewController *vc = [self getCurrentViewController];
if (vc.navigationController) {
[vc.navigationController popViewControllerAnimated:YES];
}
}
- (void)rightBtnAction:(UIButton *)sender {
[self.delegate rightBtnAction:sender];
}
- (void)changeHideState {
self.barHide = !self.barHide;
if (self.barHide) {
[UIView animateWithDuration:0.3 animations:^{
self.frame = CGRectMake(0, -64, SCREEN_W, 64);
}];
}
else {
[UIView animateWithDuration:0.3 animations:^{
self.frame = CGRectMake(0, 0, SCREEN_W, 64);
}];
}
}
/** 获取当前View的控制器对象 */
-(UIViewController *)getCurrentViewController{
UIResponder *next = [self nextResponder];
do {
if ([next isKindOfClass:[UIViewController class]]) {
return (UIViewController *)next;
}
next = [next nextResponder];
} while (next != nil);
return nil;
}
- (CGFloat)widthWithString:(NSString *)text textFontSize:(CGFloat)size {
CGRect rect = [text boundingRectWithSize:CGSizeMake(LONG_MAX, 8)options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} context:nil];
return rect.size.width;
}
@end
@@ -0,0 +1,19 @@
//
// SJPhotoPickerRaidoButton.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/22.
// Copyright © 2016年 S.J. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef void(^RadioButtonTouchedBlock)();
@interface SJPhotoPickerRaidoButton : UIButton
@property (nonatomic, assign) NSInteger pickedIndex;
@property (nonatomic, strong) RadioButtonTouchedBlock touchedBlock;
@end
@@ -0,0 +1,45 @@
//
// SJPhotoPickerRaidoButton.m
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/22.
// Copyright © 2016年 S.J. All rights reserved.
//
#import "SJPhotoPickerRaidoButton.h"
#import "SJPhotoPickerMacro.h"
@implementation SJPhotoPickerRaidoButton
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self s_setupViews];
}
return self;
}
- (void)s_setupViews {
self.titleLabel.font = [UIFont systemFontOfSize:13];
self.layer.cornerRadius = CGRectGetWidth(self.frame) * 0.5;
self.layer.masksToBounds = YES;
self.layer.borderWidth = 1;
self.layer.borderColor = [UIColor whiteColor].CGColor;
}
- (void)setPickedIndex:(NSInteger)pickedIndex{
if (pickedIndex != 0) {
self.backgroundColor = NAVBAR_CLOOUR;
[self setTitle:[NSString stringWithFormat:@"%ld",pickedIndex] forState:(UIControlStateNormal)];
}
else {
self.backgroundColor = [UIColor colorWithRed:148/255.0 green:148/255.0 blue:148/255.0 alpha:0.6];
[self setTitle:@"" forState:(UIControlStateNormal)];
}
}
@end
@@ -0,0 +1,22 @@
//
// SJPhotoPickerToolBar.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/22.
// Copyright © 2016年 S.J. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "SJPhotoPickerMacro.h"
@interface SJPhotoPickerToolBar : UIView
@property (nonatomic, strong) UIButton *leftBtn;
@property (nonatomic, strong) UIButton *rightBtn;
- (void)changePickedIndex:(NSInteger) pickedIndex;
- (void)changeHideState;
@end
@@ -0,0 +1,99 @@
//
// SJPhotoPickerToolBar.m
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/22.
// Copyright © 2016年 S.J. All rights reserved.
//
#import "SJPhotoPickerToolBar.h"
#import "SJPhotoPickerMacro.h"
@interface SJPhotoPickerToolBar()
@property (nonatomic, assign) BOOL barHide;
@end;
@implementation SJPhotoPickerToolBar
- (instancetype)init {
self = [super init];
if (self) {
self.frame = CGRectMake(0, SCREEN_H - 44, SCREEN_W, 44);
[self s_setupViews];
}
return self;
}
- (void)s_setupViews {
self.layer.shadowOffset = CGSizeMake(0, -0.3);
self.layer.shadowColor= [UIColor lightGrayColor].CGColor;
self.layer.shadowRadius = 1;
self.layer.shadowOpacity = 1;
self.backgroundColor = [UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:0.9];
self.leftBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
self.leftBtn.frame = CGRectMake(5, 7, 60, 30);
[self.leftBtn setTitleColor:NAVBAR_CLOOUR forState:(UIControlStateNormal)];
self.leftBtn.titleLabel.font = [UIFont systemFontOfSize:16];
[self.leftBtn setTitle:@"预览" forState:(UIControlStateNormal)];
[self addSubview:self.leftBtn];
self.rightBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
self.rightBtn.frame = CGRectMake(SCREEN_W - 75, 7, 65, 30);
self.rightBtn.backgroundColor = NAVBAR_CLOOUR;
[self.rightBtn setTitleColor:[UIColor colorWithRed:195/255.0 green:195/255.0 blue:195/255.0 alpha:1] forState:(UIControlStateNormal)];
self.rightBtn.layer.cornerRadius = 2;
self.rightBtn.layer.masksToBounds = YES;
self.rightBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[self.rightBtn setTitle:@"确定" forState:(UIControlStateNormal)];
[self addSubview:self.rightBtn];
self.barHide = NO;
}
- (void)changePickedIndex:(NSInteger) pickedIndex {
if (pickedIndex == 0) {
[self.leftBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
self.rightBtn.backgroundColor = NAVBAR_CLOOUR;
self.leftBtn.backgroundColor = NAVBAR_CLOOUR;
[self.rightBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
[self.rightBtn setTitle:@"确定" forState:(UIControlStateNormal)];
}
else {
self.rightBtn.backgroundColor = NAVBAR_CLOOUR;
self.leftBtn.backgroundColor = NAVBAR_CLOOUR;
[self.rightBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
[self.rightBtn setTitle:[NSString stringWithFormat:@"确定(%lu)",(unsigned long)pickedIndex] forState:(UIControlStateNormal)];
[self.leftBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
}
}
- (void)changeHideState {
self.barHide = !self.barHide;
if (self.barHide) {
[UIView animateWithDuration:0.3 animations:^{
self.frame = CGRectMake(0, SCREEN_H, SCREEN_W, 44);
}];
}
else {
[UIView animateWithDuration:0.3 animations:^{
self.frame = CGRectMake(0, SCREEN_H - 44, SCREEN_W, 44);
}];
}
}
@end
+27
View File
@@ -0,0 +1,27 @@
//
// SJPickPhotoCell.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/19.
// Copyright © 2016年 S.J. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Photos/Photos.h>
#import "SJPhotoPickerMacro.h"
#import "SJPhotoModel.h"
typedef void(^PickBtnBlock)(SJPhotoModel *curPickModel);
typedef void(^ModelChangeBlock)(SJPhotoModel *modifiedModel);
@interface SJPickPhotoCell : UICollectionViewCell
@property (nonatomic, strong) SJPhotoModel *model;
@property (nonatomic, strong) PickBtnBlock pickBtnBlock;
- (void)modelChangePickedIndex:(NSInteger)pickedIndex;
@end
+125
View File
@@ -0,0 +1,125 @@
//
// SJPickPhotoCell.m
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/19.
// Copyright © 2016年 S.J. All rights reserved.
//
#import "SJPickPhotoCell.h"
#import "SJPhotoPickerManager.h"
#import "SJPhotoPickerMacro.h"
@interface SJPickPhotoCell()
@property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UIButton *pickBtn;
@end
@implementation SJPickPhotoCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setupViews];
}
return self;
}
- (void)setupViews {
// imgView
{
self.imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0,Image_W, Image_W)];
self.imgView.contentMode = UIViewContentModeScaleAspectFit;
self.imgView.backgroundColor = NAVBAR_CLOOUR;
[self.contentView addSubview:self.imgView];
}
// pickBtn
{
self.pickBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
self.pickBtn.frame = CGRectMake(CGRectGetMaxX(self.imgView.frame) - CGRectGetWidth(self.imgView.frame) * 0.35,CGRectGetWidth(self.imgView.frame) * 0.05, CGRectGetWidth(self.imgView.frame) * 0.3, CGRectGetWidth(self.imgView.frame) * 0.3);
self.pickBtn.layer.cornerRadius = CGRectGetWidth(self.pickBtn.frame) * 0.5;
self.pickBtn.layer.masksToBounds = YES;
self.pickBtn.layer.borderWidth = 1;
self.pickBtn.layer.borderColor = [UIColor whiteColor].CGColor;
self.pickBtn.titleLabel.font = [UIFont systemFontOfSize:13];
self.pickBtn.backgroundColor = NAVBAR_CLOOUR;
[self.pickBtn addTarget:self action:@selector(pickBtnAction:) forControlEvents:(UIControlEventTouchUpInside)];
[self.contentView addSubview:self.pickBtn];
}
}
- (void)setModel:(SJPhotoModel *)model {
_model = model;
[[SJPhotoPickerManager shareSJPhotoPickerManager] requestImageForPHAsset:model.asset targetSize:CGSizeMake(Image_W, Image_W) imageResult:^(UIImage *image) {
if (image) {
self.imgView.image = image;
}
}];
if (model.pickedIndex != 0) {
[self.pickBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.pickedIndex] forState:(UIControlStateNormal)];
self.pickBtn.backgroundColor = NAVBAR_CLOOUR;
}
else {
[self.pickBtn setTitle:@"" forState:(UIControlStateNormal)];
self.pickBtn.backgroundColor = [UIColor colorWithRed:148/255.0 green:148/255.0 blue:148/255.0 alpha:0.6];
}
}
- (void)modelChangePickedIndex:(NSInteger)pickedIndex{
if (pickedIndex != 0) {
self.model.pickedIndex = pickedIndex;
self.model.isPicked = YES;
[self.pickBtn setTitle:[NSString stringWithFormat:@"%ld",(long)pickedIndex] forState:(UIControlStateNormal)];
self.pickBtn.backgroundColor = NAVBAR_CLOOUR;
[self showOscillatoryAnimationWithLayer:self.pickBtn.layer];
}
else {
self.model.pickedIndex = 0;
self.model.isPicked = NO;
[self.pickBtn setTitle:@"" forState:(UIControlStateNormal)];
self.pickBtn.backgroundColor = [UIColor colorWithRed:148/255.0 green:148/255.0 blue:148/255.0 alpha:0.6];
}
}
- (void)showOscillatoryAnimationWithLayer:(CALayer *)layer {
NSNumber *animationScale1 = @(1.15);
NSNumber *animationScale2 = @(0.85);
NSNumber *animationScale3 = @(1.0);
[UIView animateWithDuration:0.15 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations:^{
[layer setValue:animationScale1 forKeyPath:@"transform.scale"];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.15 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations:^{
[layer setValue:animationScale2 forKeyPath:@"transform.scale"];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations:^{
[layer setValue:animationScale3 forKeyPath:@"transform.scale"];
} completion:nil];
}];
}];
}
- (void)pickBtnAction:(UIButton *)sender {
self.model.isPicked = !self.model.isPicked;
self.pickBtnBlock(self.model);
}
@end
+21
View File
@@ -0,0 +1,21 @@
//
// SJPreviewPhotoCell.h
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/19.
// Copyright © 2016年 S.J. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Photos/Photos.h>
typedef void(^SingleTapEventBlock)(void);
@interface SJPreviewPhotoCell : UICollectionViewCell
@property (nonatomic, strong) PHAsset *asset;
@property (nonatomic, assign) CGFloat zoomScale;
@property (nonatomic, strong) SingleTapEventBlock singleTapEvent;
@end
+127
View File
@@ -0,0 +1,127 @@
//
// SJPreviewPhotoCell.m
// SJPhotoPickerDemo
//
// Created by Jaesun on 16/8/19.
// Copyright © 2016年 S.J. All rights reserved.
//
#import "SJPreviewPhotoCell.h"
#import "SJPhotoPickerMacro.h"
@interface SJPreviewPhotoCell() <UIScrollViewDelegate>
@property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UIScrollView *scrollView;
@end
@implementation SJPreviewPhotoCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setupViews];
}
return self;
}
- (void)setupViews {
self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
self.scrollView.delegate = self;
self.scrollView.maximumZoomScale = 4.0;
self.scrollView.minimumZoomScale = 1.0;
self.scrollView.contentSize = CGSizeMake(SCREEN_W, SCREEN_H);
[self.contentView addSubview:self.scrollView];
self.imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
self.imgView.contentMode = UIViewContentModeScaleAspectFit;
[self.scrollView addSubview:self.imgView];
UITapGestureRecognizer *singleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapGestureAction:)];
[self.scrollView addGestureRecognizer:singleTapGesture];
UITapGestureRecognizer *doubleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTapGestureAction:)];
[doubleTapGesture setNumberOfTapsRequired:2]; // Default is 1
[self.scrollView addGestureRecognizer:doubleTapGesture];
// 如果满足双击条件,单击事件触发失败,防止双击时单击事件同时被触发
[singleTapGesture requireGestureRecognizerToFail:doubleTapGesture];
}
- (void)setAsset:(PHAsset *)asset {
_asset = asset;
[[SJPhotoPickerManager shareSJPhotoPickerManager] requestImageForPHAsset:asset targetSize:PHImageManagerMaximumSize imageResult:^(UIImage *image) {
if (image) {
self.imgView.image = image;
CGFloat scale_H = SCREEN_H / image.size.height;
CGFloat scale_W = SCREEN_W / image.size.width;
CGSize size;
if (scale_H > scale_W) {
size = CGSizeMake(SCREEN_W, scale_W * image.size.height);
}
else if (scale_H < scale_W) {
size = CGSizeMake(scale_H * image.size.width, SCREEN_H);
}
self.imgView.frame = CGRectMake(0, 0, size.width, size.height);
self.imgView.center = self.scrollView.center;
}
}];
}
- (void)setZoomScale:(CGFloat)zoomScale {
_zoomScale = zoomScale;
[UIView animateWithDuration:0.3 animations:^{
self.scrollView.zoomScale = zoomScale;
}];
}
- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
CGSize viewSize = self.imgView.frame.size;
CGPoint centerPoint;
if (viewSize.width<=CGRectGetWidth(self.bounds) && viewSize.height<=CGRectGetHeight(self.bounds)) {
centerPoint = CGPointMake(CGRectGetWidth(self.bounds)*0.5f, CGRectGetHeight(self.bounds)*0.5f);
}else if (viewSize.width>=CGRectGetWidth(self.bounds) && viewSize.height>=CGRectGetHeight(self.bounds) ){
centerPoint = CGPointMake(scrollView.contentSize.width*0.5f, scrollView.contentSize.height*0.5f);
}else if (viewSize.width<=CGRectGetWidth(self.bounds) && viewSize.height>=CGRectGetHeight(self.bounds) ){
centerPoint = CGPointMake(CGRectGetWidth(self.bounds)*0.5f, scrollView.contentSize.height*0.5f);
}else if ((viewSize.width >= CGRectGetWidth(self.bounds)) && (viewSize.height <= CGRectGetHeight(self.bounds))){
centerPoint = CGPointMake(scrollView.contentSize.width*0.5f, CGRectGetHeight(self.bounds)*0.5f);
}
self.imgView.center = centerPoint;
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return self.imgView;
}
- (void)singleTapGestureAction:(UITapGestureRecognizer *)sender {
self.singleTapEvent();
}
- (void)doubleTapGestureAction:(UITapGestureRecognizer *)sender {
if (self.zoomScale == 4) {
self.zoomScale = 1;
}else {
CGFloat newScale = self.zoomScale * 2.0f;
self.zoomScale = newScale;
}
}
@end
+2 -1
View File
@@ -114,6 +114,7 @@ alpha:((float)(rgbValue & 0xFF))/255.0]
//HUD
#define HUD_DISPLAY_DURATION 2
#define HUD_TIMEOUT_DURATION 8
//分享图片文件名
#define kUSERSHAREA_IMAGENAME @"mask_share"
#endif /* GIGA_h */
+1
View File
@@ -18,6 +18,7 @@
#import <UMAnalytics/MobClick.h>
#endif
#import "GiGaUserDefault.h"
#import "GIGA.h"
//#import "AFNetworking.h"
@@ -11,8 +11,10 @@
#import "MaskTimeTimeViewCell.h"
#import "MaskTimeEndActionViewCell.h"
#import "ShareViewController.h"
@interface GIGaMaskShareViewController ()
#import "MaskTimeShareActionSheet.h"
#import "GIGaUserFileHelper.h"
#import <AVFoundation/AVFoundation.h>
@interface GIGaMaskShareViewController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate>
@end
@@ -99,7 +101,36 @@
#pragma mark changeBackBtnAction
-(void)changeBackBtnAction{
MaskTimeShareActionSheet * sheet = [[MaskTimeShareActionSheet alloc] initWithFrame:CGRectMake(0, 0, KMainW, KMainH)];
[sheet show:^(NSUInteger index) {
switch (index) {
case 0:
{//手机
[self photosAlbum];
}
break;
case 1:
{
//系统
[GIGaUserFileHelper delectShareImage:kUSERSHAREA_IMAGENAME];
ShareViewController *share = [[ShareViewController alloc] init];
[self presentViewController:share animated:NO completion:nil];
}
break;
case 2:
{
//自拍
[self takePhoto];
}
break;
default:
break;
}
}];
[self.view addSubview:sheet];
}
#pragma mark share
@@ -110,4 +141,91 @@
}
#pragma mark 相册
-(void)photosAlbum{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init]; imagePickerController.delegate = self; imagePickerController.allowsEditing = YES;
//相册
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
//权限
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:imagePickerController animated:YES completion:nil];
}else{
NSString *errorStr = @"应用相权册限受限,请在设置中启用";
[self jxt_showAlertWithTitle:@"" message:errorStr appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"取消");
alertMaker.addActionDefaultTitle(@"去开启");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
if (buttonIndex == 1) {
NSURL *url = [NSURL URLWithString:@"prefs:root=Photos"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
}
}];
}
}
-(void)takePhoto{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init]; imagePickerController.delegate = self; imagePickerController.allowsEditing = YES;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//权限判断应用是否有使用相机的权限
NSString *mediaType = AVMediaTypeVideo;//读取媒体类型
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];//读取设备授权状态
if(authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied){
NSString *errorStr = @"应用相机权限受限,请在设置中启用";
[self jxt_showAlertWithTitle:@"" message:errorStr appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"取消");
alertMaker.addActionDefaultTitle(@"去开启");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
if (buttonIndex == 1) {
NSString *urlStr = @"App-Prefs:root=Photos";
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr] options:@{} completionHandler:nil];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];
// Fallback on earlier versions
}
}
}];
return;
}
// 设置数据源
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:imagePickerController animated:YES completion:nil];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
{
GILog(@"info:%@",info);
[picker dismissViewControllerAnimated:YES completion:nil]
;
UIImage*img=[info objectForKey:UIImagePickerControllerEditedImage];
UIImage *small = [GIGaUserFileHelper zipScaleWithImage:img];
[GIGaUserFileHelper savaShareImange:kUSERSHAREA_IMAGENAME image:small];
ShareViewController *share = [[ShareViewController alloc] init];
[self presentViewController:share animated:NO completion:nil];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
[picker dismissViewControllerAnimated:YES completion:nil];
}
@end
@@ -122,13 +122,15 @@
-(void)connetction{
NSURL* url = [[NSURL alloc] initWithString:@"http://wsyts.s1.natapp.cc"];
//@"connectParams":@{@"token":@""}
NSString *token = [GiGaUserDefault getCurentToken];
if (!token) {
token = @"";
}
SocketManager *manager = [[SocketManager alloc] initWithSocketURL:url config:@{@"log": @NO, @"forcePolling": @YES,@"extraHeaders":@{@"device":@"ios"},@"token":token}];
NSString *urlstr = [NSString stringWithFormat:@"http://wsyts.s1.natapp.cc"];
NSURL* url = [[NSURL alloc] initWithString:urlstr];
SocketManager *manager = [[SocketManager alloc] initWithSocketURL:url config:@{@"log": @NO, @"forcePolling": @YES,@"extraHeaders":@{@"device":@"ios"},@"connectParams":@{@"token":token}}];
_manager = manager;
_client = manager.defaultSocket;
@@ -502,9 +502,9 @@
// resultVC.model = model;
// [self.navigationController pushViewController:resultVC animated:YES];
[self showAlertGoShareMaskTime];
//[self showAlertGoShareMaskTime];
return;
GiGaQuestionVC *questionVC = [[GiGaQuestionVC alloc] init];
[self.navigationController pushViewController:questionVC animated:YES];
@@ -667,6 +667,7 @@
- (void)progressDidFish{
NSLog(@"结束");
[self maskTimeEnd];
[self showAlertGoShareMaskTime];
}
- (void)didReceiveMemoryWarning {
@@ -10,9 +10,10 @@
#import "MaskTimeShareViewCell.h"
#import "MaskShareTimeMidViewCell.h"
#import "MaskShareBoootomViewCell.h"
@interface ShareViewController ()<UITableViewDelegate,UITableViewDataSource>
#import "MaskTimeShareActionSheet.h"
#import "GIGaUserFileHelper.h"
#import <AVFoundation/AVFoundation.h>
@interface ShareViewController ()<UITableViewDelegate,UITableViewDataSource,UIImagePickerControllerDelegate,UINavigationControllerDelegate>
@property(nonatomic,strong) UITableView *tab;
@property(nonatomic,strong) UIImageView *backimageview ;
@property(nonatomic) int curentImageIndex ;
@@ -27,9 +28,11 @@
_curentImageIndex = 0;
UIImageView *backimageview = [[UIImageView alloc] init];
backimageview.contentMode = UIViewContentModeScaleAspectFill;
backimageview.frame = CGRectMake(0, 0,self.view.frame.size.width, self.view.frame.size.height);
backimageview.userInteractionEnabled = YES;
backimageview.image = [UIImage imageNamed:@"sharebg_1"];
backimageview.image = [GIGaUserFileHelper getUserShareImage:kUSERSHAREA_IMAGENAME];
// self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"sharebg_1"]];
self.backimageview = backimageview;
[self.view addSubview:backimageview];
@@ -37,7 +40,7 @@
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
backBtn.frame = CGRectMake(20,44, 40, 40);
[backBtn setImage:[UIImage imageNamed:@"btn_moment_back"] forState:UIControlStateNormal];
backBtn.backgroundColor = [UIColor redColor];
[backBtn addTarget:self action:@selector(backBtnAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:backBtn];
[self.view insertSubview:backimageview atIndex:0];
@@ -145,19 +148,132 @@
-(void)changeAction{
_curentImageIndex ++;
if (_curentImageIndex == 4) {
_curentImageIndex = 0;
MaskTimeShareActionSheet * sheet = [[MaskTimeShareActionSheet alloc] initWithFrame:CGRectMake(0, 0, KMainW, KMainH)];
[sheet show:^(NSUInteger index) {
switch (index) {
case 0:
{//手机
[self photosAlbum];
}
break;
case 1:
{
//系统
self->_curentImageIndex ++;
if (self->_curentImageIndex == 4) {
self->_curentImageIndex = 0;
}
NSArray *images = @[@"sharebg_2",@"sharebg_3",@"sharebg_4",@"sharebg_5",@"sharebg_1"];
[self.backimageview setImage:[UIImage imageNamed: images[self->_curentImageIndex]]];
}
break;
case 2:
{
//自拍
[self takePhoto];
}
break;
default:
break;
}
}];
[self.view addSubview:sheet];
}
#pragma mark 相册
-(void)photosAlbum{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init]; imagePickerController.delegate = self; imagePickerController.allowsEditing = YES;
//相册
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
//权限
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:imagePickerController animated:YES completion:nil];
}else{
NSString *errorStr = @"应用相权册限受限,请在设置中启用";
[self jxt_showAlertWithTitle:@"" message:errorStr appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"取消");
alertMaker.addActionDefaultTitle(@"去开启");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
if (buttonIndex == 1) {
NSURL *url = [NSURL URLWithString:@"prefs:root=Photos"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
}
}];
}
NSArray *images = @[@"sharebg_2",@"sharebg_3",@"sharebg_4",@"sharebg_5",@"sharebg_1"];
[self.backimageview setImage:[UIImage imageNamed: images[_curentImageIndex]]];
}
-(void)takePhoto{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init]; imagePickerController.delegate = self; imagePickerController.allowsEditing = YES;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//权限判断应用是否有使用相机的权限
NSString *mediaType = AVMediaTypeVideo;//读取媒体类型
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];//读取设备授权状态
if(authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied){
NSString *errorStr = @"应用相机权限受限,请在设置中启用";
[self jxt_showAlertWithTitle:@"" message:errorStr appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"取消");
alertMaker.addActionDefaultTitle(@"去开启");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
if (buttonIndex == 1) {
NSString *urlStr = @"App-Prefs:root=Photos";
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr] options:@{} completionHandler:nil];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];
// Fallback on earlier versions
}
}
}];
return;
}
// 设置数据源
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:imagePickerController animated:YES completion:nil];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
{
GILog(@"info:%@",info);
[picker dismissViewControllerAnimated:YES completion:nil]
;
UIImage*img=[info objectForKey:UIImagePickerControllerEditedImage];
UIImage *small = [GIGaUserFileHelper zipScaleWithImage:img];
[GIGaUserFileHelper savaShareImange:kUSERSHAREA_IMAGENAME image:small];
ShareViewController *share = [[ShareViewController alloc] init];
[self presentViewController:share animated:NO completion:nil];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
[picker dismissViewControllerAnimated:YES completion:nil];
}
-(void)shareBtnAction{
}
@end
@@ -356,6 +356,7 @@
}
-(void)submitAnswer{
NSDictionary *params = @{@"singleChoiceList":self.answerArray};
@@ -375,8 +376,19 @@
BOOL isUserLogin = [GiGaUserDefault isUserLogin];
if (isUserLogin) {
//展示结果
MaskTestResultVC *reusltVC = [[MaskTestResultVC alloc] init];
[self.navigationController pushViewController:reusltVC animated:YES];
NSDictionary *dic = @{
@"dryness":@"0.41",
@"drynessPercent":@"41%",
@"mask":@"",
@"minute":@"19",
@"oiliness":@"0.59",
@"oilinessPercent":@"59%"
};
MaskTestResult *model =[[MaskTestResult alloc] initWithDictionary:dic error:nil];
MaskTestResultVC *resultVC = [[MaskTestResultVC alloc] init];
resultVC.model = model;
[self.navigationController pushViewController:resultVC animated:YES];
}else{
[self jxt_showAlertWithTitle:@"对不起您还没有登录" message:@"请登录后查看肤质测试结果" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"返回首页");
@@ -10,7 +10,7 @@
#import "MaskResultMinViewCell.h"
#import "MaskResultPercentCell.h"
#import "MaskResultShareViewCell.h"
#import "SHareTestImageVC.h"
#import "GiGaFileNanager.h"
@@ -130,7 +130,7 @@
table.frame = savedFrame;
UIGraphicsEndImageContext();
[[GiGaFileNanager shareInstance] saveImaeToAlBum:image];
[[GiGaFileNanager shareInstance] saveImaeToAlBum:image];
return image;
@@ -1,14 +0,0 @@
//
// SHareTestImageVC.h
// GIGA
//
// Created by lianxiang on 2018/9/21.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import "GiGaBaseViewController.h"
@interface SHareTestImageVC : GiGaBaseViewController
@property (nonatomic,strong) UIImage *image ;
@end
@@ -1,43 +0,0 @@
//
// SHareTestImageVC.m
// GIGA
//
// Created by lianxiang on 2018/9/21.
// Copyright © 2018 com.giga.ios. All rights reserved.
//
#import "SHareTestImageVC.h"
@interface SHareTestImageVC ()
@end
@implementation SHareTestImageVC
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
UIImageView *ima = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height)];
ima.contentMode = UIViewContentModeScaleAspectFit;
ima.image = self.image;
[self.view addSubview:ima];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13142" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12042"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="SHareTestImageVC">
<connections>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="Q5M-cg-NOt"/>
</view>
</objects>
</document>
@@ -0,0 +1,15 @@
//
// MaskActionSheetViewCell.h
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface MaskActionSheetViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *sheetTitle;
-(void)comfirmTitles:(NSIndexPath *)indepath;
@end
@@ -0,0 +1,29 @@
//
// MaskActionSheetViewCell.m
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018 com.giga.ios. All rights reserved.
//
#import "MaskActionSheetViewCell.h"
@implementation MaskActionSheetViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
-(void)comfirmTitles:(NSIndexPath *)indepath
{
NSArray *titles = @[@"手机相册",@"系统相册",@"自拍"];
self.sheetTitle.text = titles[indepath.row];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="MaskActionSheetViewCell" id="KGk-i7-Jjw" customClass="MaskActionSheetViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="40V-PX-LhN">
<rect key="frame" x="137" y="8" width="47" height="26"/>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="18"/>
<color key="textColor" red="0.51372549019607838" green="0.039215686274509803" blue="0.039215686274509803" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ngI-qP-hKZ">
<rect key="frame" x="0.0" y="43.5" width="320" height="0.5"/>
<color key="backgroundColor" red="0.87058823529411766" green="0.87058823529411766" blue="0.87058823529411766" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="0.5" id="cs5-Qf-Vk6"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="40V-PX-LhN" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="Fgn-aW-scP"/>
<constraint firstAttribute="trailing" secondItem="ngI-qP-hKZ" secondAttribute="trailing" id="Hx7-pI-vWZ"/>
<constraint firstItem="ngI-qP-hKZ" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="UY4-gg-DTG"/>
<constraint firstItem="40V-PX-LhN" firstAttribute="centerX" secondItem="H2p-sc-9uM" secondAttribute="centerX" id="WWw-Zh-jsa"/>
<constraint firstAttribute="bottom" secondItem="ngI-qP-hKZ" secondAttribute="bottom" constant="-0.5" id="yOL-n1-moT"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
<connections>
<outlet property="sheetTitle" destination="40V-PX-LhN" id="jzf-mX-x9L"/>
</connections>
</tableViewCell>
</objects>
</document>
@@ -0,0 +1,15 @@
//
// MaskTimeShareActionSheet.h
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef void (^actionSheetAction)(NSUInteger index);
@interface MaskTimeShareActionSheet : UIView
@property(nonatomic,copy) actionSheetAction action;
-(void)show:(actionSheetAction)action;
@end
@@ -0,0 +1,116 @@
//
// MaskTimeShareActionSheet.m
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018 com.giga.ios. All rights reserved.
//
#import "MaskTimeShareActionSheet.h"
#import "MaskActionSheetViewCell.h"
@interface MaskTimeShareActionSheet()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong) UITableView *tabview;
@end
@implementation MaskTimeShareActionSheet
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3]; ;
[self creatUI];
}
return self;
}
-(void)creatUI{
UIView *holdview =[[UIView alloc] init];
holdview.frame =CGRectMake(0,KMainH - 216 - 60 -20 , KMainW, 216 + 60 +20);
holdview.backgroundColor = [UIColor whiteColor];
// CGRect backRect= holdview.frame;
//
// UIBezierPath *maskPath=[UIBezierPath bezierPathWithRoundedRect:backRect byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(15, 15)];
// CAShapeLayer *maskLayer =[[CAShapeLayer alloc] init];
// maskLayer.frame = backRect;
// maskLayer.path = maskPath.CGPath;
// holdview.layer.mask = maskLayer;
holdview.layer.masksToBounds = YES;
holdview.layer.cornerRadius = 10;
[self addSubview:holdview];
self.tabview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KMainW, 216 + 60) style:UITableViewStylePlain];
self.tabview.backgroundColor = [UIColor whiteColor];
self.tabview.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tabview.delegate = self;
self.tabview.scrollEnabled = NO;
self.tabview.dataSource = self;
UIButton *cancleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[cancleBtn setTitle:@"取消" forState:UIControlStateNormal];
[cancleBtn setTitleColor:GIGARGB(165,165, 165, 1) forState:UIControlStateNormal];
[cancleBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
cancleBtn.frame = CGRectMake(0,1, KMainW,60);
self.tabview.tableFooterView = cancleBtn;
[holdview addSubview:self.tabview];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
MaskActionSheetViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MaskActionSheetViewCell"];
if (!cell) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"MaskActionSheetViewCell" owner:self options:nil] lastObject];
}
[cell comfirmTitles:indexPath];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 54;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (self.action) {
self.action(indexPath.row);
[self cancleDissmiss];
}
}
-(void)show:(actionSheetAction)action{
self.action = action;
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
if ([touches anyObject].view != self.tabview) {
[self cancleDissmiss];
}
}
-(void)cancelAction{
[self cancleDissmiss];
}
-(void)cancleDissmiss{
[UIView animateWithDuration:1.0 animations:^{
self.tabview.frame = CGRectMake(0, KMainH - 216, KMainW, 0);
}];
[self removeFromSuperview];
}
@end
@@ -7,6 +7,13 @@
//
#import "GiGaFeedBackViewController.h"
#import "GIGaFeedQQViewCell.h"
#import "GIGaFeedPhontosViewCell.h"
#import "GiGaFeedContentViewCell.h"
#import "GiGaFeedLeiIingViewCell.h"
#import "SJPhotoPicker.h"
#import "GiGaNetManager.h"
#import "GiGaAPIResult.h"
@interface GiGaFeedBackViewController ()
@@ -17,7 +24,171 @@
- (void)viewDidLoad {
[super viewDidLoad];
[self addNavTitile:@"意见反馈"];
[self.view addSubview:self.tableView];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.backgroundColor = GIGA_MAIN_BGCOLOR;
self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
self.tableView.sectionFooterHeight = 0;
self.tableView.estimatedSectionFooterHeight= 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.frame = CGRectMake(0, 1, KMainW, self.view.bounds.size.height - SAFE_NAV_HEIGHT);
[self.tableView registerClass:[GIGaFeedPhontosViewCell class] forCellReuseIdentifier:@"GIGaFeedPhontosViewCell"];
// Do any additional setup after loading the view.
UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 80)];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.layer.masksToBounds = YES;
btn.layer.cornerRadius = 20;
btn.frame = CGRectMake((self.view.frame.size.width - 245) /2 , 20, 245,40);
btn.backgroundColor = [UIColor whiteColor];
NSAttributedString *atti = [GiGaHelper stringWithText:@"提交" textColor:GIGA_MAIN_BGCOLOR textFont:GIGA_TEXTFONTBOLD(18) leterSpace:0];
[btn addTarget:self action:@selector(tijiaoAction) forControlEvents:UIControlEventTouchUpInside];
[btn setAttributedTitle:atti forState:UIControlStateNormal];
[footer addSubview:btn];
self.tableView.tableFooterView = footer;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 4;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
GiGaFeedLeiIingViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GiGaFeedLeiIingViewCell"];
if (!cell) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"GiGaFeedLeiIingViewCell" owner:self options:nil] lastObject];
}
return cell;
}else if (indexPath.section == 1){
GiGaFeedContentViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GiGaFeedContentViewCell"];
if (!cell) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"GiGaFeedContentViewCell" owner:self options:nil] lastObject];
}
return cell;
}else if (indexPath.section == 2){
GIGaFeedQQViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GIGaFeedQQViewCell"];
if (!cell) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaFeedQQViewCell" owner:self options:nil] lastObject];
}
return cell;
}else if (indexPath.section == 3){
GIGaFeedPhontosViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GIGaFeedPhontosViewCell"];
if (!cell) {
cell = [[GIGaFeedPhontosViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"GIGaFeedPhontosViewCell"];;
}
__weak typeof(cell) weakCell = cell;
cell.pickerBalock = ^{
[[SJPhotoPicker shareSJPhotoPicker] showPhotoPickerToController:self pickedAssets:^(NSArray<PHAsset *> *assets) {
// 6
// if ((weakCell.images.count + assets.count) > 6) {
// GIGA_ShowToast(@"最多六张");
// return ;
// }
[weakCell.images addObjectsFromArray:assets];
//weakSelf.images = [NSMutableArray arrayWithArray:assets];
[weakCell.collectionView reloadData];
}];
};
return cell;
}
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
return 40;
}else if (indexPath.section == 1){
return 142;
}else if (indexPath.section == 2){
return 40;
}else if (indexPath.section == 3){
return 218;
}
return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section == 3) {
return 36;
}else{
return 12;
}
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
if (section == 3) {
UIView *view = [[UIView alloc] init];
UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake(15,0, 200, 36);
label.font = GIGA_TEXTFONTMEDIUM(13);
label.text= @"上传图片(最多6张)";
label.textColor = [UIColor whiteColor];
[view addSubview:label];
return view;
}
UIView *view = [[UIView alloc] init];
return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.1;
}
#pragma mark 提交
-(void)tijiaoAction{
GIGaFeedPhontosViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:3]];
NSArray *names =cell.imageNames;
NSLog(@"names:%@",names);
GiGaFeedLeiIingViewCell *kindcell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
if ([kindcell.kidLabel.text isEqualToString:@"选择反馈类型"]) {
GIGA_ShowToast(@"请选择评论类型");
return;
}
GiGaFeedContentViewCell *contencell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1]];
if (contencell.contentFiled.text.length==0) {
GIGA_ShowToast(@"请输入评论");
return;
}
GIGaFeedQQViewCell *qqcell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:3]];
if (qqcell.QTextFiled.text.length == 0) {
qqcell.QTextFiled.text = @"";
}
if (names.count <= 0) {
GIGA_ShowToast(@"请选择图片");
return;
}
[GiGaNetManager uploadImage:@"sys/sysdict/v1/maskproposaltype" imageNames:names parms:@{} responseBlock:^(NSDictionary *responseDict, NSDictionary *responseHeaderFields, NSError *error) {
if (error) {
GILog(@"err:%@",error.localizedDescription);
}else{
GiGaAPIResult *result = [[GiGaAPIResult alloc] initWithDictionary:responseDict];
GIGA_ShowToast(result.message);
}
}];
}
- (void)didReceiveMemoryWarning {
@@ -25,14 +196,6 @@
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
@@ -298,7 +298,7 @@
}
int leng = [GiGaHelper convertToInt: self.user.nickName];
if ( leng >40 ) {
if ( self.user.nickName.length >40 ) {
GIGA_ShowToast(@"用户名1-40字符长度")
return;
}
@@ -0,0 +1,17 @@
//
// GIGaFeedImagsCollectionCell.h
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface GIGaFeedImagsCollectionCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UIImageView *uploadImageView;
@property (weak, nonatomic) IBOutlet UIButton *delecBtn;
@property (weak, nonatomic) IBOutlet UIView *holdView;
@property (weak, nonatomic) IBOutlet UIImageView *holdImageView;
@end
@@ -0,0 +1,20 @@
//
// GIGaFeedImagsCollectionCell.m
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018 com.giga.ios. All rights reserved.
//
#import "GIGaFeedImagsCollectionCell.h"
@implementation GIGaFeedImagsCollectionCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
[self.holdView bringSubviewToFront:self.delecBtn];
}
@end
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="GIGaFeedImagsCollectionCell" id="gTV-IL-0wX" customClass="GIGaFeedImagsCollectionCell">
<rect key="frame" x="0.0" y="0.0" width="104" height="104"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="104" height="104"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="j5W-en-Qt6">
<rect key="frame" x="0.0" y="0.0" width="104" height="104"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="img_holder" translatesAutoresizingMaskIntoConstraints="NO" id="OI4-At-zxC">
<rect key="frame" x="30" y="22" width="44" height="61"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="x1H-ve-Fgf">
<rect key="frame" x="54" y="0.0" width="50" height="43"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="43" id="F0v-0l-iMj"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="50" id="Fz8-ZA-RPb"/>
<constraint firstAttribute="height" constant="43" id="l0y-pL-Dc1"/>
<constraint firstAttribute="width" constant="50" id="wna-nz-SXe"/>
</constraints>
<inset key="imageEdgeInsets" minX="25" minY="0.0" maxX="0.0" maxY="17"/>
<state key="normal" image="btn_back"/>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="0OC-Nu-4Es">
<rect key="frame" x="0.0" y="0.0" width="104" height="104"/>
</imageView>
</subviews>
<color key="backgroundColor" red="0.87058823529999996" green="0.87058823529999996" blue="0.87058823529999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="OI4-At-zxC" firstAttribute="top" secondItem="j5W-en-Qt6" secondAttribute="top" constant="22" id="4LG-wM-F44"/>
<constraint firstItem="0OC-Nu-4Es" firstAttribute="leading" secondItem="j5W-en-Qt6" secondAttribute="leading" id="AwC-NQ-dKH"/>
<constraint firstItem="0OC-Nu-4Es" firstAttribute="top" secondItem="j5W-en-Qt6" secondAttribute="top" id="F26-JE-MfS"/>
<constraint firstAttribute="trailing" secondItem="x1H-ve-Fgf" secondAttribute="trailing" id="Slm-mX-H0J"/>
<constraint firstItem="x1H-ve-Fgf" firstAttribute="top" secondItem="j5W-en-Qt6" secondAttribute="top" id="Sok-Vd-Aaf"/>
<constraint firstAttribute="trailing" secondItem="OI4-At-zxC" secondAttribute="trailing" constant="30" id="XGW-QQ-a0R"/>
<constraint firstAttribute="bottom" secondItem="OI4-At-zxC" secondAttribute="bottom" constant="21" id="iSn-Io-4fL"/>
<constraint firstAttribute="bottom" secondItem="0OC-Nu-4Es" secondAttribute="bottom" id="jz8-lK-9jD"/>
<constraint firstItem="OI4-At-zxC" firstAttribute="leading" secondItem="j5W-en-Qt6" secondAttribute="leading" constant="30" id="kzn-UF-b6Y"/>
<constraint firstAttribute="trailing" secondItem="0OC-Nu-4Es" secondAttribute="trailing" id="sLW-N6-cte"/>
</constraints>
</view>
</subviews>
</view>
<constraints>
<constraint firstAttribute="trailing" secondItem="j5W-en-Qt6" secondAttribute="trailing" id="65s-PX-QHc"/>
<constraint firstItem="j5W-en-Qt6" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="EHN-cC-fqn"/>
<constraint firstAttribute="bottom" secondItem="j5W-en-Qt6" secondAttribute="bottom" id="NC9-vb-9D2"/>
<constraint firstItem="j5W-en-Qt6" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="eCP-n4-EO0"/>
</constraints>
<viewLayoutGuide key="safeArea" id="SEy-5g-ep8"/>
<connections>
<outlet property="delecBtn" destination="x1H-ve-Fgf" id="INd-yD-1pz"/>
<outlet property="holdImageView" destination="OI4-At-zxC" id="oBf-Rq-vfK"/>
<outlet property="holdView" destination="j5W-en-Qt6" id="gzn-Kv-Cam"/>
<outlet property="uploadImageView" destination="0OC-Nu-4Es" id="Igo-Ca-Fx3"/>
</connections>
</collectionViewCell>
</objects>
<resources>
<image name="btn_back" width="22" height="22"/>
<image name="img_holder" width="51" height="43"/>
</resources>
</document>
@@ -0,0 +1,19 @@
//
// GIGaFeedPhontosViewCell.h
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Photos/PHAsset.h>
typedef void(^GiGaPhotoPickerBlock)(void);
@interface GIGaFeedPhontosViewCell : UITableViewCell
@property(nonatomic,copy) GiGaPhotoPickerBlock pickerBalock;
@property(nonatomic,strong) NSMutableArray *images;
@property(nonatomic,strong) UICollectionView *collectionView;
-(void)photoPikerComplete:(GiGaPhotoPickerBlock)pikerComplete;
@property(nonatomic,strong) NSMutableArray *imageNames;
@end
@@ -0,0 +1,188 @@
//
// GIGaFeedPhontosViewCell.m
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018 com.giga.ios. All rights reserved.
//
#import "GIGaFeedPhontosViewCell.h"
#import "GIGaFeedImagsCollectionCell.h"
#import "GiGaFeedImagsActionCell.h"
#import "SJPhotoPickerManager.h"
#import "SJPhotoPicker.h"
#import "GIGaUserFileHelper.h"
@interface GIGaFeedPhontosViewCell()<UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout>
@end
@implementation GIGaFeedPhontosViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
_images = [NSMutableArray new];
[self creatUI];
}
return self;
}
- (NSMutableArray *)imageNames{
if (!_imageNames) {
_imageNames = [NSMutableArray new];
}
return _imageNames;
}
-(void)creatUI{
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
flowLayout.minimumLineSpacing = 1;
flowLayout.minimumInteritemSpacing = .1;
CGFloat width = (KMainW-15*2 - 22*2)/3;
flowLayout.itemSize = CGSizeMake(width,width);
//
//CGFloat HCELL= (itemH*1+1)*2;
_collectionView=[[UICollectionView alloc]initWithFrame:CGRectMake(0,0,KMainW, 218) collectionViewLayout:flowLayout];
_collectionView.delegate=self;
_collectionView.dataSource=self;
_collectionView.bounces=NO;
_collectionView.scrollEnabled=NO;
_collectionView.showsVerticalScrollIndicator=NO;
_collectionView.backgroundColor = GIGA_MAIN_BGCOLOR;
[self addSubview:_collectionView];
[_collectionView registerNib:[UINib nibWithNibName:@"GiGaFeedImagsActionCell" bundle:nil] forCellWithReuseIdentifier:@"GiGaFeedImagsActionCell"];
[_collectionView registerNib:[UINib nibWithNibName:@"GIGaFeedImagsCollectionCell" bundle:nil] forCellWithReuseIdentifier:@"GIGaFeedImagsCollectionCell"];
}
#pragma mark <UICollectionViewDataSource>
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return 1 + self.images.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == self.images.count) {
GiGaFeedImagsActionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"GiGaFeedImagsActionCell" forIndexPath:indexPath];
if (!cell) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"GiGaFeedImagsActionCell" owner:self options:nil] lastObject];
}
[cell.imageAdd addTarget:self action:@selector(addBtnAction:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
GIGaFeedImagsCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"GIGaFeedImagsCollectionCell" forIndexPath:indexPath];
if (!cell) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaFeedImagsCollectionCell" owner:self options:nil] lastObject];
}
cell.delecBtn.tag = indexPath.row;
[cell.delecBtn addTarget:self action:@selector(delecBtnAction:) forControlEvents:UIControlEventTouchUpInside];
//PHImageManagerMaximumSize
[self.imageNames removeAllObjects];
[[SJPhotoPickerManager shareSJPhotoPickerManager] requestImageForPHAsset:self.images[indexPath.row] targetSize:CGSizeMake(200, 200) imageResult:^(UIImage *image) {
cell.uploadImageView.image = image;
if (image) {
cell.holdImageView.hidden = YES;
}else{
cell.holdImageView.hidden = NO;
}
cell.holdView.backgroundColor = [UIColor clearColor];
NSString *name = [NSString stringWithFormat:@"gigafeed_index%ld",(long)indexPath.row];
[GIGaUserFileHelper saveUserFeedbackImag:name image:image];
if ([self.imageNames containsObject: name]) {
[self.imageNames removeObject:name];
}
[self.imageNames addObject:name];
}];
return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat width = (KMainW-15*2 - 22*2)/3;
CGSize itemSize = CGSizeMake(width,width);
return itemSize;
}
//
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(0,15,0, 15);
}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
//
return 22.0f;
}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
//
return 10.0f;
}
-(void)delecBtnAction:(UIButton *)btn{
GILog(@"删除");
NSUInteger index = btn.tag;
[self.images removeObjectAtIndex:index];
[GIGaUserFileHelper delectAllfeedimages];
[self.imageNames removeAllObjects];
[self.collectionView reloadData];
}
-(void)addBtnAction:(UIButton*)btn{
if (self.pickerBalock) {
self.pickerBalock();
}
}
- (void)photoPikerComplete:(GiGaPhotoPickerBlock)pikerComplete{
if (self.pickerBalock) {
self.pickerBalock = pikerComplete;
}
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
@@ -0,0 +1,15 @@
//
// GIGaFeedQQViewCell.h
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface GIGaFeedQQViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UITextField *QTextFiled;
@end
@@ -0,0 +1,24 @@
//
// GIGaFeedQQViewCell.m
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018 com.giga.ios. All rights reserved.
//
#import "GIGaFeedQQViewCell.h"
@implementation GIGaFeedQQViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="GIGaFeedQQViewCell" id="KGk-i7-Jjw" customClass="GIGaFeedQQViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wzf-76-7C1">
<rect key="frame" x="15" y="0.0" width="290" height="44"/>
<subviews>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="手机/邮箱/QQ" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Wtv-qw-ARD">
<rect key="frame" x="14" y="6" width="261" height="33"/>
<constraints>
<constraint firstAttribute="height" constant="33" id="mQh-Pp-SNm"/>
</constraints>
<color key="textColor" red="0.75686274509803919" green="0.75686274509803919" blue="0.75686274509803919" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="13"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Wtv-qw-ARD" firstAttribute="centerY" secondItem="wzf-76-7C1" secondAttribute="centerY" id="CdQ-gv-ktH"/>
<constraint firstItem="Wtv-qw-ARD" firstAttribute="leading" secondItem="wzf-76-7C1" secondAttribute="leading" constant="14" id="oHV-7F-CIq"/>
<constraint firstAttribute="trailing" secondItem="Wtv-qw-ARD" secondAttribute="trailing" constant="15" id="rEL-dx-AOc"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="wzf-76-7C1" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="15" id="MCC-cD-Kmh"/>
<constraint firstItem="wzf-76-7C1" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="dSK-l2-Ked"/>
<constraint firstItem="wzf-76-7C1" firstAttribute="height" secondItem="H2p-sc-9uM" secondAttribute="height" id="eqo-yc-ffi"/>
<constraint firstAttribute="trailing" secondItem="wzf-76-7C1" secondAttribute="trailing" constant="15" id="gxV-s1-8ig"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" red="0.51372549020000002" green="0.039215686270000001" blue="0.039215686270000001" alpha="1" colorSpace="calibratedRGB"/>
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
<connections>
<outlet property="QTextFiled" destination="Wtv-qw-ARD" id="B0a-V2-ffA"/>
</connections>
</tableViewCell>
</objects>
</document>
@@ -0,0 +1,17 @@
//
// GiGaFeedContentViewCell.h
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface GiGaFeedContentViewCell : UITableViewCell<UITextViewDelegate>
@property (weak, nonatomic) IBOutlet UITextView *contentFiled;
@property (weak, nonatomic) IBOutlet UILabel *holdLabe;
@property (weak, nonatomic) IBOutlet UILabel *numberCountLabe;
@property (nonatomic,strong) NSString *textMAx;
@end
@@ -0,0 +1,61 @@
//
// GiGaFeedContentViewCell.m
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018 com.giga.ios. All rights reserved.
//
#import "GiGaFeedContentViewCell.h"
@implementation GiGaFeedContentViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
self.contentFiled.delegate =self;
}
- (void)textViewDidBeginEditing:(UITextView *)textView{
if (textView == self.contentFiled) {
self.holdLabe.hidden = YES;
}
}
- (void)textViewDidChange:(UITextView *)textView
{
if (textView == self.contentFiled) {
if (textView.text.length == 0) {
self.holdLabe.hidden = NO;
}
if ( textView.text.length <=100 ) {
self.numberCountLabe.text = [NSString stringWithFormat:@"%lu/100",(unsigned long)textView.text.length];
self.contentFiled.text = textView.text;
self.textMAx = textView.text;
}else{
textView.text = self.textMAx;
}
}
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
// if ( textView.text.length >100 ) {
//
// return NO;
// }
return YES;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="GiGaFeedContentViewCell" id="KGk-i7-Jjw" customClass="GiGaFeedContentViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="142"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="141.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nRM-PI-P0X">
<rect key="frame" x="15" y="0.0" width="290" height="142"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="D4t-0d-ayG">
<rect key="frame" x="10" y="0.0" width="268" height="142"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="textColor" red="0.75686274509803919" green="0.75686274509803919" blue="0.75686274509803919" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="13"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0/100" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6ey-qR-EDX">
<rect key="frame" x="223" y="115" width="36" height="19"/>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="13"/>
<color key="textColor" red="0.1764705882352941" green="0.1764705882352941" blue="0.1764705882352941" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="来了就说几句吧~" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="TLh-tj-C89">
<rect key="frame" x="14" y="8" width="105" height="19"/>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="13"/>
<color key="textColor" red="0.75686274509999996" green="0.75686274509999996" blue="0.75686274509999996" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="D4t-0d-ayG" firstAttribute="centerY" secondItem="nRM-PI-P0X" secondAttribute="centerY" id="EHj-eM-2kn"/>
<constraint firstAttribute="trailing" secondItem="6ey-qR-EDX" secondAttribute="trailing" constant="31" id="FK7-pv-afK"/>
<constraint firstAttribute="trailing" secondItem="D4t-0d-ayG" secondAttribute="trailing" constant="12" id="MJo-rQ-g8F"/>
<constraint firstItem="TLh-tj-C89" firstAttribute="leading" secondItem="nRM-PI-P0X" secondAttribute="leading" constant="14" id="YH1-Rd-AZx"/>
<constraint firstAttribute="bottom" secondItem="6ey-qR-EDX" secondAttribute="bottom" constant="8" id="Yq4-es-zmm"/>
<constraint firstItem="D4t-0d-ayG" firstAttribute="height" secondItem="nRM-PI-P0X" secondAttribute="height" id="Zcd-Mh-Sak"/>
<constraint firstItem="TLh-tj-C89" firstAttribute="top" secondItem="nRM-PI-P0X" secondAttribute="top" constant="8" id="cmF-R5-xvZ"/>
<constraint firstItem="D4t-0d-ayG" firstAttribute="leading" secondItem="nRM-PI-P0X" secondAttribute="leading" constant="10" id="wdz-mP-xbZ"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="nRM-PI-P0X" secondAttribute="trailing" constant="15" id="2KC-jP-QlB"/>
<constraint firstItem="nRM-PI-P0X" firstAttribute="height" secondItem="H2p-sc-9uM" secondAttribute="height" id="ChH-Nb-WGV"/>
<constraint firstItem="nRM-PI-P0X" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="15" id="PfZ-i6-10r"/>
<constraint firstItem="nRM-PI-P0X" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="UuE-HW-Hxu"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" red="0.51372549020000002" green="0.039215686270000001" blue="0.039215686270000001" alpha="1" colorSpace="calibratedRGB"/>
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
<connections>
<outlet property="contentFiled" destination="D4t-0d-ayG" id="gfZ-CZ-dHf"/>
<outlet property="holdLabe" destination="TLh-tj-C89" id="e83-Wv-Snm"/>
<outlet property="numberCountLabe" destination="6ey-qR-EDX" id="5hH-Ae-moq"/>
</connections>
</tableViewCell>
</objects>
</document>
@@ -0,0 +1,14 @@
//
// GiGaFeedImagsActionCell.h
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface GiGaFeedImagsActionCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UIButton *imageAdd;
@end
@@ -0,0 +1,18 @@
//
// GiGaFeedImagsActionCell.m
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018 com.giga.ios. All rights reserved.
//
#import "GiGaFeedImagsActionCell.h"
@implementation GiGaFeedImagsActionCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
@end
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="GiGaFeedImagsActionCell">
<rect key="frame" x="0.0" y="0.0" width="104" height="104"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="104" height="104"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="p4F-LQ-Mgo">
<rect key="frame" x="0.0" y="0.0" width="104" height="104"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="img_camera" translatesAutoresizingMaskIntoConstraints="NO" id="PNN-vx-9XC">
<rect key="frame" x="27" y="19" width="50" height="67"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="aOT-f4-LRi">
<rect key="frame" x="0.0" y="0.0" width="104" height="104"/>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="aOT-f4-LRi" firstAttribute="leading" secondItem="p4F-LQ-Mgo" secondAttribute="leading" id="101-Yv-yNU"/>
<constraint firstItem="aOT-f4-LRi" firstAttribute="leading" secondItem="p4F-LQ-Mgo" secondAttribute="leading" id="4fs-og-ovQ"/>
<constraint firstAttribute="bottom" secondItem="aOT-f4-LRi" secondAttribute="bottom" id="57z-nN-ezQ"/>
<constraint firstItem="PNN-vx-9XC" firstAttribute="leading" secondItem="p4F-LQ-Mgo" secondAttribute="leading" constant="27" id="9So-vG-wnQ"/>
<constraint firstAttribute="trailing" secondItem="aOT-f4-LRi" secondAttribute="trailing" id="IgC-Sy-mac"/>
<constraint firstItem="aOT-f4-LRi" firstAttribute="top" secondItem="p4F-LQ-Mgo" secondAttribute="top" id="MZN-X1-hFr"/>
<constraint firstAttribute="bottom" secondItem="PNN-vx-9XC" secondAttribute="bottom" constant="18" id="N3W-xo-blq"/>
<constraint firstAttribute="trailing" secondItem="aOT-f4-LRi" secondAttribute="trailing" id="gRL-cn-YfY"/>
<constraint firstItem="PNN-vx-9XC" firstAttribute="top" secondItem="p4F-LQ-Mgo" secondAttribute="top" constant="19" id="hf8-gT-7Cs"/>
<constraint firstAttribute="bottom" secondItem="aOT-f4-LRi" secondAttribute="bottom" id="j7a-2n-lmS"/>
<constraint firstAttribute="trailing" secondItem="PNN-vx-9XC" secondAttribute="trailing" constant="27" id="ksJ-F4-Qht"/>
<constraint firstItem="aOT-f4-LRi" firstAttribute="top" secondItem="p4F-LQ-Mgo" secondAttribute="top" id="nCc-n1-PPA"/>
</constraints>
</view>
</subviews>
</view>
<constraints>
<constraint firstItem="p4F-LQ-Mgo" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="ca0-vZ-Eds"/>
<constraint firstAttribute="trailing" secondItem="p4F-LQ-Mgo" secondAttribute="trailing" id="fBl-J5-XBM"/>
<constraint firstItem="p4F-LQ-Mgo" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="wFG-CR-yWw"/>
<constraint firstAttribute="bottom" secondItem="p4F-LQ-Mgo" secondAttribute="bottom" id="yUE-Oe-gvn"/>
</constraints>
<viewLayoutGuide key="safeArea" id="SEy-5g-ep8"/>
<connections>
<outlet property="imageAdd" destination="aOT-f4-LRi" id="has-hX-ccK"/>
</connections>
</collectionViewCell>
</objects>
<resources>
<image name="img_camera" width="54" height="48"/>
</resources>
</document>
@@ -0,0 +1,14 @@
//
// GiGaFeedLeiIingViewCell.h
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface GiGaFeedLeiIingViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *kidLabel;
@end
@@ -0,0 +1,24 @@
//
// GiGaFeedLeiIingViewCell.m
// GIGA
//
// Created by lianxiang on 2018/9/22.
// Copyright © 2018 com.giga.ios. All rights reserved.
//
#import "GiGaFeedLeiIingViewCell.h"
@implementation GiGaFeedLeiIingViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="GiGaFeedLeiIingViewCell" id="KGk-i7-Jjw" customClass="GiGaFeedLeiIingViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="amZ-ba-Om2">
<rect key="frame" x="15" y="0.0" width="290" height="44"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="bg_moreandmore_red" translatesAutoresizingMaskIntoConstraints="NO" id="hQC-14-kEw">
<rect key="frame" x="275" y="15" width="9" height="14"/>
<constraints>
<constraint firstAttribute="width" constant="9" id="SAd-5C-zb8"/>
<constraint firstAttribute="height" constant="14" id="agY-nO-dFa"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="选择反馈类型" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6lu-rs-JV8">
<rect key="frame" x="14" y="13" width="79" height="19"/>
<constraints>
<constraint firstAttribute="width" constant="79" id="it2-tZ-9bc"/>
</constraints>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="13"/>
<color key="textColor" red="0.1764705882352941" green="0.1764705882352941" blue="0.1764705882352941" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="hQC-14-kEw" firstAttribute="centerY" secondItem="amZ-ba-Om2" secondAttribute="centerY" id="NBv-tA-YHO"/>
<constraint firstItem="6lu-rs-JV8" firstAttribute="centerY" secondItem="amZ-ba-Om2" secondAttribute="centerY" id="lQi-w4-iGA"/>
<constraint firstAttribute="trailing" secondItem="hQC-14-kEw" secondAttribute="trailing" constant="6" id="mlv-BR-iwm"/>
<constraint firstItem="6lu-rs-JV8" firstAttribute="leading" secondItem="amZ-ba-Om2" secondAttribute="leading" constant="14" id="uDa-Qt-n2a"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="amZ-ba-Om2" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="15" id="S0A-Ug-Uqf"/>
<constraint firstAttribute="trailing" secondItem="amZ-ba-Om2" secondAttribute="trailing" constant="15" id="Uom-VJ-ir3"/>
<constraint firstItem="amZ-ba-Om2" firstAttribute="height" secondItem="H2p-sc-9uM" secondAttribute="height" id="alS-XN-7dq"/>
<constraint firstItem="amZ-ba-Om2" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="tx5-6X-UEP"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" red="0.51372549019607838" green="0.039215686274509803" blue="0.039215686274509803" alpha="1" colorSpace="calibratedRGB"/>
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
<connections>
<outlet property="kidLabel" destination="6lu-rs-JV8" id="FX8-d4-4Fj"/>
</connections>
<point key="canvasLocation" x="-14" y="-13"/>
</tableViewCell>
</objects>
<resources>
<image name="bg_moreandmore_red" width="9" height="14"/>
</resources>
</document>