Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
Opple-iOS
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张杰
Opple-iOS
Commits
faa497b2
Commit
faa497b2
authored
Apr 19, 2017
by
Sandy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
评论添加图片
parent
f54c92a9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
608 additions
and
58 deletions
+608
-58
CommentListTableViewCell.m
.../ComprehensiveDiscussion/Cells/CommentListTableViewCell.m
+57
-2
ForumItemDetailViewController.m
...iveDiscussion/Controllers/ForumItemDetailViewController.m
+20
-7
ForumCommentListViewModel.h
...ehensiveDiscussion/ViewModels/ForumCommentListViewModel.h
+18
-0
ForumCommentListViewModel.m
...ehensiveDiscussion/ViewModels/ForumCommentListViewModel.m
+31
-0
ForumDetailBottomView.h
...ter/ComprehensiveDiscussion/Views/ForumDetailBottomView.h
+2
-0
ForumDetailBottomView.m
...ter/ComprehensiveDiscussion/Views/ForumDetailBottomView.m
+4
-0
ZJKeyBoardAccessoryView.h
...r/ComprehensiveDiscussion/Views/ZJKeyBoardAccessoryView.h
+10
-0
ZJKeyBoardAccessoryView.m
...r/ComprehensiveDiscussion/Views/ZJKeyBoardAccessoryView.m
+87
-26
project.pbxproj
Lighting.xcodeproj/project.pbxproj
+20
-0
LearningCenter.storyboard
Lighting/LearningCenter.storyboard
+22
-23
UIImage+Helper.h
Tools/Category/UIImage+Helper.h
+67
-0
UIImage+Helper.m
Tools/Category/UIImage+Helper.m
+270
-0
No files found.
Class/LearningCenter/ComprehensiveDiscussion/Cells/CommentListTableViewCell.m
View file @
faa497b2
...
...
@@ -7,7 +7,10 @@
//
#import "CommentListTableViewCell.h"
#import "MWPhotoBrowser.h"
@interface
CommentListTableViewCell
()
<
MWPhotoBrowserDelegate
>
@property
(
nonatomic
,
strong
)
NSMutableArray
*
browserArray
;
@end
@implementation
CommentListTableViewCell
-
(
void
)
awakeFromNib
{
...
...
@@ -23,6 +26,7 @@
for
(
UIImageView
*
obj
in
self
.
attachmentView
.
subviews
)
{
if
([
obj
isKindOfClass
:[
UIImageView
class
]])
{
obj
.
userInteractionEnabled
=
YES
;
UITapGestureRecognizer
*
tap
=
[[
UITapGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
tapImage
:
)];
[
obj
addGestureRecognizer
:
tap
];
}
...
...
@@ -30,7 +34,38 @@
}
-
(
void
)
tapImage
:
(
UIGestureRecognizer
*
)
tap
{
NSLog
(
@"%lu"
,
tap
.
view
.
tag
);
if
(
tap
.
view
.
tag
+
1
>
self
.
replyEntity
.
attachments
.
count
)
{
return
;
}
[
self
.
browserArray
removeAllObjects
];
for
(
TOAttachmentEntity
*
att
in
self
.
replyEntity
.
attachments
)
{
MWPhoto
*
photo
=
[
MWPhoto
photoWithURL
:[
NSURL
URLWithString
:
att
.
fileUrl
]];
[
self
.
browserArray
addObject
:
photo
];
}
MWPhotoBrowser
*
browser
=
[[
MWPhotoBrowser
alloc
]
initWithDelegate
:
self
];
[
browser
setCurrentPhotoIndex
:
tap
.
view
.
tag
];
UINavigationController
*
nav
=
[[
UINavigationController
alloc
]
initWithRootViewController
:
browser
];
[
self
.
viewController
.
navigationController
presentViewController
:
nav
animated
:
YES
completion
:
nil
];
}
#pragma mark - <MWPhotoBrowserDelegate>
-
(
NSUInteger
)
numberOfPhotosInPhotoBrowser
:
(
MWPhotoBrowser
*
)
photoBrowser
{
return
self
.
browserArray
.
count
;
}
-
(
id
<
MWPhoto
>
)
photoBrowser
:
(
MWPhotoBrowser
*
)
photoBrowser
photoAtIndex
:
(
NSUInteger
)
index
{
if
(
index
<
self
.
browserArray
.
count
)
{
return
[
self
.
browserArray
objectAtIndex
:
index
];
}
return
nil
;
}
-
(
NSString
*
)
photoBrowser
:
(
MWPhotoBrowser
*
)
photoBrowser
titleForPhotoAtIndex
:
(
NSUInteger
)
index
{
return
[
NSString
stringWithFormat
:
@"%ld/%ld"
,
index
+
1
,
self
.
browserArray
.
count
];
}
#pragma mark - 选项按钮
-
(
IBAction
)
extensionButtonClickAction
:
(
UIButton
*
)
sender
{
...
...
@@ -59,6 +94,26 @@
self
.
bestView
.
isBest
=
_replyEntity
.
best
;
self
.
bestView
.
indexPath
=
self
.
indexPath
;
self
.
baseImageView
.
hidden
=
!
_replyEntity
.
best
;
if
(
replyEntity
.
attachments
.
count
>
0
)
{
self
.
layoutAttHeight
.
constant
=
164
;
}
else
{
self
.
layoutAttHeight
.
constant
=
0
;
}
for
(
NSInteger
i
=
0
;
i
<
replyEntity
.
attachments
.
count
;
i
++
)
{
TOAttachmentEntity
*
att
=
replyEntity
.
attachments
[
i
];
UIImageView
*
imgView
=
(
UIImageView
*
)[
self
.
attachmentView
viewWithTag
:
i
];
[
imgView
sd_setImageWithURL
:[
NSURL
URLWithString
:
att
.
fileUrl
]
placeholderImage
:
REPLACEIMAGE
];
}
}
#pragma mark - lazy
-
(
NSMutableArray
*
)
browserArray
{
if
(
!
_browserArray
)
{
_browserArray
=
[
NSMutableArray
array
];
}
return
_browserArray
;
}
@end
Class/LearningCenter/ComprehensiveDiscussion/Controllers/ForumItemDetailViewController.m
View file @
faa497b2
...
...
@@ -16,6 +16,8 @@
#import "ZJKeyBoardAccessoryView.h"
#import "ForumDetailBottomView.h"
#import "OSSHelper.h"
#import "ForumCommentListViewModel.h"
#import "UIImage+Helper.h"
@interface
ForumItemDetailViewController
()
<
UITableViewDelegate
,
UITableViewDataSource
,
UITextFieldDelegate
,
TapClickDelegate
,
ReturnTableviewcellIndexpathdelegate
>
...
...
@@ -170,7 +172,12 @@
weakSelf
.
commentsArray
=
nil
;
}
weakSelf
.
topicReply
=
[[
ForumReplyResponse
alloc
]
initWithDictionary
:
RESPONSE
(
returnValue
)
error
:
nil
];
[
weakSelf
.
commentsArray
addObjectsFromArray
:
weakSelf
.
topicReply
.
forumReplyEntity
];
for
(
CustomTOForumReplyEntity
*
entity
in
weakSelf
.
topicReply
.
forumReplyEntity
)
{
ForumCommentListViewModel
*
model
=
[
ForumCommentListViewModel
new
];
model
.
replyEntity
=
entity
;
[
weakSelf
.
commentsArray
addObject
:
model
];
}
[
weakSelf
setUpCommentNumber
];
[
weakSelf
.
forumDetailTableView
reloadData
];
}
else
{
...
...
@@ -230,7 +237,8 @@
CommentListTableViewCell
*
commentCell
=
[
tableView
dequeueReusableCellWithIdentifier
:
@"CommentListTableViewCell"
forIndexPath
:
indexPath
];
commentCell
.
bestView
.
delegate
=
self
;
commentCell
.
indexPath
=
indexPath
;
commentCell
.
replyEntity
=
self
.
commentsArray
[
indexPath
.
row
];
ForumCommentListViewModel
*
cellModel
=
self
.
commentsArray
[
indexPath
.
row
];
commentCell
.
replyEntity
=
cellModel
.
replyEntity
;
BOOL
boolValue
=
([
self
.
topicDetail
.
posterId
isEqualToString
:[
Shoppersmanager
manager
].
shoppers
.
employee
.
fid
]
&&
[
self
.
category
.
name
isEqualToString
:
OPPLE_ASK
]);
commentCell
.
optionButton
.
hidden
=
!
boolValue
;
return
commentCell
;
...
...
@@ -256,9 +264,9 @@
}
break
;
}
CustomTOForumReplyEntity
*
replyEntity
=
self
.
commentsArray
[
indexPath
.
row
];
ForumCommentListViewModel
*
cellModel
=
self
.
commentsArray
[
indexPath
.
row
];
//68为上边距 10为下边距
return
replyEntity
.
replyContentHeight
+
68
+
10
;
return
cellModel
.
height
;
}
-
(
void
)
tableView
:
(
UITableView
*
)
tableView
didEndDisplayingCell
:
(
UITableViewCell
*
)
cell
forRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
...
...
@@ -309,10 +317,13 @@
#pragma mark - 上传图片附件
-
(
void
)
uploadAttachments
:
(
void
(
^
)(
NSArray
*
OSSKeys
))
finish
{
if
(
self
.
bottomView
.
toolView
.
arrSelectedPhotos
.
count
==
0
)
{
finish
(
nil
);
return
;
}
NSMutableArray
*
OSSKeyArray
=
[
NSMutableArray
array
];
for
(
int
i
=
0
;
i
<
self
.
bottomView
.
toolView
.
arrSelectedPhotos
.
count
;
i
++
)
{
[
OSSKeyArray
addObject
:[
OSSHelper
getOSSObjectKeyWithtype
:
@"
pn
g"
index
:
i
]];
[
OSSKeyArray
addObject
:[
OSSHelper
getOSSObjectKeyWithtype
:
@"
jp
g"
index
:
i
]];
}
XBLoadingView
*
loadView
=
[
XBLoadingView
showHUDViewProgressLabel
:[
NSString
stringWithFormat
:
@"图片上传中:1/%ld"
,
self
.
bottomView
.
toolView
.
arrSelectedPhotos
.
count
]];
static
NSInteger
number
=
0
;
...
...
@@ -321,7 +332,8 @@
for
(
int
i
=
0
;
i
<
self
.
bottomView
.
toolView
.
arrSelectedPhotos
.
count
;
i
++
)
{
UIImage
*
image
=
self
.
bottomView
.
toolView
.
arrSelectedPhotos
[
i
];
NSString
*
ossKey
=
OSSKeyArray
[
i
];
NSData
*
data
=
UIImagePNGRepresentation
(
image
);
UIImage
*
newSizeImage
=
[
image
scaledToWidth
:
1024
];
NSData
*
data
=
[
newSizeImage
scaledToSpaceMaxSize
:
200
];
[
OSSHelper
uploadImageObjectWithKey
:
ossKey
data
:
data
type
:
OSSHelperOperationTypeSynchronous
progress
:^
(
int64_t
bytesSent
,
int64_t
totalBytesSent
,
int64_t
totalBytesExpectedToSend
)
{
CGFloat
totalBytesSentFloat
=
totalBytesSent
;
CGFloat
totalBytesExpectedToSendFloat
=
totalBytesExpectedToSend
;
...
...
@@ -394,6 +406,7 @@
[
XBLoadingView
hideHUDViewWithDefault
];
if
(
RESULT
(
returnValue
))
{
weakSelf
.
commentInputTextFieldView
.
text
=
nil
;
[
weakSelf
.
bottomView
clearPhoto
];
[
XBLoadingView
showHUDViewWithSuccessText
:
@"评论成功"
completeBlock
:
^
{
if
(
weakSelf
.
refreshBlock
)
{
weakSelf
.
refreshBlock
(
ONE
,
Comment
,
weakSelf
.
indexPath
);
...
...
Class/LearningCenter/ComprehensiveDiscussion/ViewModels/ForumCommentListViewModel.h
0 → 100644
View file @
faa497b2
//
// ForumCommentListViewModel.h
// Lighting
//
// Created by Javen on 2017/4/18.
// Copyright © 2017年 上海勾芒科技有限公司. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface
ForumCommentListViewModel
:
NSObject
/**
回复数据源
*/
@property
(
nonatomic
,
strong
)
CustomTOForumReplyEntity
*
replyEntity
;
@property
(
nonatomic
,
assign
)
CGFloat
height
;
@end
Class/LearningCenter/ComprehensiveDiscussion/ViewModels/ForumCommentListViewModel.m
0 → 100644
View file @
faa497b2
//
// ForumCommentListViewModel.m
// Lighting
//
// Created by Javen on 2017/4/18.
// Copyright © 2017年 上海勾芒科技有限公司. All rights reserved.
//
#import "ForumCommentListViewModel.h"
static
UILabel
*
stringLabel
=
nil
;
@implementation
ForumCommentListViewModel
-
(
void
)
setReplyEntity
:(
CustomTOForumReplyEntity
*
)
replyEntity
{
_replyEntity
=
replyEntity
;
self
.
height
=
88
;
if
(
replyEntity
.
attachments
.
count
>
0
)
{
self
.
height
=
88
+
164
;
}
static
dispatch_once_t
onceToken
;
dispatch_once
(
&
onceToken
,
^
{
//生成一个用于计算文本高度的label
stringLabel
=
[[
UILabel
alloc
]
init
];
stringLabel
.
font
=
[
UIFont
systemFontOfSize
:
17
];
stringLabel
.
numberOfLines
=
0
;
});
stringLabel
.
text
=
replyEntity
.
replyContent
;
self
.
height
=
self
.
height
+
[
stringLabel
sizeThatFits
:
CGSizeMake
(
ScreenWidth
-
40
,
MAXFLOAT
)].
height
+
16
;
NSLog
(
@"%f"
,
self
.
height
);
}
@end
Class/LearningCenter/ComprehensiveDiscussion/Views/ForumDetailBottomView.h
View file @
faa497b2
...
...
@@ -16,4 +16,6 @@
*/
@property
(
strong
,
nonatomic
)
ZJKeyBoardAccessoryView
*
toolView
;
@property
(
weak
,
nonatomic
)
IBOutlet
NSLayoutConstraint
*
layoutHeight
;
-
(
void
)
clearPhoto
;
@end
Class/LearningCenter/ComprehensiveDiscussion/Views/ForumDetailBottomView.m
View file @
faa497b2
...
...
@@ -54,6 +54,10 @@
return
cell
;
}
-
(
void
)
clearPhoto
{
[
self
.
toolView
deleteAll
];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
...
...
Class/LearningCenter/ComprehensiveDiscussion/Views/ZJKeyBoardAccessoryView.h
View file @
faa497b2
...
...
@@ -13,5 +13,15 @@
@property
(
strong
,
nonatomic
)
NSMutableArray
*
arrSelectedPhotos
;
@property
(
nonatomic
,
copy
)
void
(
^
blockFinishSelected
)(
void
);
/**
删除指定下标的图片
@param index 下标
*/
-
(
void
)
deletePhotoWithIndex
:(
NSInteger
)
index
;
/**
删除所有的图片
*/
-
(
void
)
deleteAll
;
@end
Class/LearningCenter/ComprehensiveDiscussion/Views/ZJKeyBoardAccessoryView.m
View file @
faa497b2
...
...
@@ -28,7 +28,7 @@ typedef NS_ENUM(NSInteger, ItemIndex) {
@property
(
strong
,
nonatomic
)
NSMutableArray
*
allPhotoArray
;
/**
<#Description#>
*/
@property
(
strong
,
nonatomic
)
NSMutableArray
*
mwPhotoArray
;
...
...
@@ -36,6 +36,7 @@ typedef NS_ENUM(NSInteger, ItemIndex) {
缩略图
*/
@property
(
strong
,
nonatomic
)
NSMutableArray
*
thumbsArray
;
@property
(
strong
,
nonatomic
)
NSMutableDictionary
*
cache
;
@end
@implementation
ZJKeyBoardAccessoryView
...
...
@@ -100,10 +101,14 @@ typedef NS_ENUM(NSInteger, ItemIndex) {
#pragma mark - <UIImagePickerControllerDelegate>
-
(
void
)
imagePickerController
:
(
UIImagePickerController
*
)
picker
didFinishPickingMediaWithInfo
:
(
NSDictionary
<
NSString
*
,
id
>
*
)
info
{
// [self.navigationControll
er dismissViewControllerAnimated:YES completion:nil];
[
pick
er
dismissViewControllerAnimated
:
YES
completion
:
nil
];
UIImage
*
headImage
=
[
info
objectForKey
:
UIImagePickerControllerOriginalImage
];
// [self.selectedImageArray addObject:headImage];
// [self.publishTableView reloadData];
[
self
.
arrSelectedPhotos
addObject
:
headImage
];
if
(
self
.
blockFinishSelected
)
{
self
.
blockFinishSelected
();
}
}
#pragma mark - 相册选择照片
...
...
@@ -132,11 +137,31 @@ typedef NS_ENUM(NSInteger, ItemIndex) {
-
(
void
)
photoBrowser
:
(
MWPhotoBrowser
*
)
photoBrowser
photoAtIndex
:
(
NSUInteger
)
index
selectedChanged
:
(
BOOL
)
selected
{
PHAsset
*
currentPhoto
=
self
.
allPhotoArray
[
index
];
if
(
selected
)
{
[
self
.
arrSelectedAssets
addObject
:
currentPhoto
];
}
else
{
PHImageManager
*
imageManager
=
[
PHImageManager
defaultManager
];
PHImageRequestOptions
*
options
=
[
PHImageRequestOptions
new
];
options
.
networkAccessAllowed
=
YES
;
options
.
resizeMode
=
PHImageRequestOptionsResizeModeFast
;
options
.
deliveryMode
=
PHImageRequestOptionsDeliveryModeHighQualityFormat
;
options
.
synchronous
=
YES
;
WS
(
weakSelf
);
[
imageManager
requestImageForAsset
:
currentPhoto
targetSize
:
CGSizeMake
(
ScreenWidth
,
ScreenHeight
)
contentMode
:
PHImageContentModeAspectFit
options
:
options
resultHandler
:^
(
UIImage
*
result
,
NSDictionary
*
info
)
{
[
self
.
arrSelectedAssets
addObject
:
currentPhoto
];
[
weakSelf
.
arrSelectedPhotos
addObject
:
result
];
[
weakSelf
.
cache
setObject
:
result
forKey
:
currentPhoto
];
}];
}
else
{
id
result
=
[
self
.
cache
objectForKey
:
currentPhoto
];
[
self
.
arrSelectedAssets
removeObject
:
currentPhoto
];
[
self
.
arrSelectedPhotos
removeObject
:
result
];
}
}
-
(
void
)
photoBrowserDidFinishModalPresentation
:
(
MWPhotoBrowser
*
)
photoBrowser
{
...
...
@@ -144,24 +169,24 @@ typedef NS_ENUM(NSInteger, ItemIndex) {
[
XBLoadingView
showHUDViewWithText
:
@"图片最多选择3张"
];
return
;
}
PHImageManager
*
imageManager
=
[
PHImageManager
defaultManager
];
PHImageRequestOptions
*
options
=
[
PHImageRequestOptions
new
];
options
.
networkAccessAllowed
=
YES
;
options
.
resizeMode
=
PHImageRequestOptionsResizeModeFast
;
options
.
deliveryMode
=
PHImageRequestOptionsDeliveryModeHighQualityFormat
;
options
.
synchronous
=
YES
;
WS
(
weakSelf
);
[
self
.
arrSelectedPhotos
removeAllObjects
];
for
(
PHAsset
*
asset
in
self
.
arrSelectedAssets
)
{
[
imageManager
requestImageForAsset
:
asset
targetSize
:
CGSizeMake
(
ScreenWidth
,
ScreenHeight
)
contentMode
:
PHImageContentModeAspectFit
options
:
options
resultHandler
:^
(
UIImage
*
result
,
NSDictionary
*
info
)
{
[
weakSelf
.
arrSelectedPhotos
addObject
:
result
];
}];
}
//
//
PHImageManager *imageManager = [PHImageManager defaultManager];
//
PHImageRequestOptions *options = [PHImageRequestOptions new];
//
options.networkAccessAllowed = YES;
//
options.resizeMode = PHImageRequestOptionsResizeModeFast;
//
options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
//
options.synchronous = YES;
//
WS(weakSelf);
//
[self.arrSelectedPhotos removeAllObjects];
//
for (PHAsset *asset in self.arrSelectedAssets) {
//
[imageManager requestImageForAsset:asset
//
targetSize:CGSizeMake(ScreenWidth, ScreenHeight)
//
contentMode:PHImageContentModeAspectFit
//
options:options
// resultHandler:^(UIImage *result, NSDictionary *info)
{
//
[weakSelf.arrSelectedPhotos addObject:result];
//
}];
//
}
if
(
self
.
blockFinishSelected
)
{
self
.
blockFinishSelected
();
...
...
@@ -172,7 +197,12 @@ typedef NS_ENUM(NSInteger, ItemIndex) {
}
-
(
void
)
selectAlbumImage
{
if
(
!
[
BaseViewController
determinePhotosPermissions
])
{
UIAlertController
*
alertVC
=
[
UIAlertController
alertControllerWithTitle
:
@"提示"
message
:
@"请在iPad的“设置-隐私-相册”选项中,允许欧立方访问你的相册"
preferredStyle
:
UIAlertControllerStyleAlert
];
[
alertVC
addAction
:[
UIAlertAction
actionWithTitle
:
@"知道了"
style
:
UIAlertActionStyleCancel
handler
:
nil
]];
[
self
.
viewController
presentViewController
:
alertVC
animated
:
YES
completion
:
nil
];
return
;
}
MWPhotoBrowser
*
browser
=
[[
MWPhotoBrowser
alloc
]
initWithDelegate
:
self
];
browser
.
displayActionButton
=
YES
;
browser
.
displayNavArrows
=
YES
;
...
...
@@ -186,10 +216,34 @@ typedef NS_ENUM(NSInteger, ItemIndex) {
[
self
.
viewController
.
navigationController
presentViewController
:
nav
animated
:
YES
completion
:
nil
];
}
-
(
void
)
deletePhotoWithIndex
:
(
NSInteger
)
index
{
[
self
.
arrSelectedAssets
removeObjectAtIndex
:
index
];
[
self
.
arrSelectedPhotos
removeObjectAtIndex
:
index
];
UIImage
*
image
=
self
.
arrSelectedPhotos
[
index
];
//如果要删除的照片在缓存里面,那么这是相册选择的照片,需要从缓存删除
for
(
PHAsset
*
key
in
self
.
cache
.
allKeys
)
{
UIImage
*
cacheImage
=
[
self
.
cache
objectForKey
:
key
];
if
([
cacheImage
isEqual
:
image
])
{
[
self
.
cache
removeObjectForKey
:
key
];
[
self
.
arrSelectedAssets
removeObject
:
key
];
break
;
}
}
[
self
.
arrSelectedPhotos
removeObject
:
image
];
if
(
self
.
blockFinishSelected
)
{
self
.
blockFinishSelected
();
}
}
/**
删除所有的图片
*/
-
(
void
)
deleteAll
{
[
self
.
arrSelectedAssets
removeAllObjects
];
[
self
.
arrSelectedPhotos
removeAllObjects
];
[
self
.
cache
removeAllObjects
];
if
(
self
.
blockFinishSelected
)
{
self
.
blockFinishSelected
();
}
...
...
@@ -233,6 +287,13 @@ typedef NS_ENUM(NSInteger, ItemIndex) {
return
_arrSelectedPhotos
;
}
-
(
NSDictionary
*
)
cache
{
if
(
!
_cache
)
{
_cache
=
[
NSMutableDictionary
dictionary
];
}
return
_cache
;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
...
...
Lighting.xcodeproj/project.pbxproj
View file @
faa497b2
...
...
@@ -338,6 +338,8 @@
8F0FD1A11EA48EC500D38035
/* ForumDetailBottomView.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8F0FD1A01EA48EC500D38035
/* ForumDetailBottomView.m */
;
};
8F0FD1A41EA494EA00D38035
/* ForumDetailBottomPictureCell.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8F0FD1A31EA494EA00D38035
/* ForumDetailBottomPictureCell.m */
;
};
8F0FD1A71EA4A8BF00D38035
/* ZJKeyBoardAccessoryView.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8F0FD1A61EA4A8BF00D38035
/* ZJKeyBoardAccessoryView.m */
;
};
8F7B45461EA61FED00E52092
/* ForumCommentListViewModel.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8F7B45451EA61FED00E52092
/* ForumCommentListViewModel.m */
;
};
8FEF03F31EA7543F00837A64
/* UIImage+Helper.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8FEF03F21EA7543F00837A64
/* UIImage+Helper.m */
;
};
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
...
...
@@ -985,6 +987,10 @@
8F0FD1A31EA494EA00D38035
/* ForumDetailBottomPictureCell.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
ForumDetailBottomPictureCell.m
;
sourceTree
=
"<group>"
;
};
8F0FD1A51EA4A8BF00D38035
/* ZJKeyBoardAccessoryView.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
ZJKeyBoardAccessoryView.h
;
sourceTree
=
"<group>"
;
};
8F0FD1A61EA4A8BF00D38035
/* ZJKeyBoardAccessoryView.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
ZJKeyBoardAccessoryView.m
;
sourceTree
=
"<group>"
;
};
8F7B45441EA61FED00E52092
/* ForumCommentListViewModel.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
ForumCommentListViewModel.h
;
sourceTree
=
"<group>"
;
};
8F7B45451EA61FED00E52092
/* ForumCommentListViewModel.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
ForumCommentListViewModel.m
;
sourceTree
=
"<group>"
;
};
8FEF03F11EA7543F00837A64
/* UIImage+Helper.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"UIImage+Helper.h"
;
sourceTree
=
"<group>"
;
};
8FEF03F21EA7543F00837A64
/* UIImage+Helper.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"UIImage+Helper.m"
;
sourceTree
=
"<group>"
;
};
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
...
...
@@ -1777,6 +1783,8 @@
2901738A1E0A22940005F48B
/* UIButton+countDown.m */
,
298111101DFE674600F7EAFF
/* UIImage+Fit.h */
,
298111111DFE674600F7EAFF
/* UIImage+Fit.m */
,
8FEF03F11EA7543F00837A64
/* UIImage+Helper.h */
,
8FEF03F21EA7543F00837A64
/* UIImage+Helper.m */
,
2962D07F1CD1E6010058829D
/* UIView+Frame.h */
,
2962D0801CD1E6010058829D
/* UIView+Frame.m */
,
2916A7461D703A1700644C8C
/* UIView+cornerRadius.h */
,
...
...
@@ -2311,6 +2319,7 @@
29C30BD71DDC1E8C00CA3E29
/* ComprehensiveDiscussion */
=
{
isa
=
PBXGroup
;
children
=
(
8F7B45431EA61FB700E52092
/* ViewModels */
,
2999B1301DE6CD760031F79E
/* Cells */
,
2999B12C1DE6CD4F0031F79E
/* Controllers */
,
298111171DFE9F2C00F7EAFF
/* Models */
,
...
...
@@ -2885,6 +2894,15 @@
name
=
Pods
;
sourceTree
=
"<group>"
;
};
8F7B45431EA61FB700E52092
/* ViewModels */
=
{
isa
=
PBXGroup
;
children
=
(
8F7B45441EA61FED00E52092
/* ForumCommentListViewModel.h */
,
8F7B45451EA61FED00E52092
/* ForumCommentListViewModel.m */
,
);
path
=
ViewModels
;
sourceTree
=
"<group>"
;
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
...
...
@@ -3095,6 +3113,7 @@
files
=
(
293163FA1DCE3CBA0075129D
/* LuckyDrawDetailsViewController.m in Sources */
,
29CC51ED1E8A011E009FBB6A
/* RebateDetailsViewController.m in Sources */
,
8F7B45461EA61FED00E52092
/* ForumCommentListViewModel.m in Sources */
,
29045F321DCA192700E42A86
/* PromptHeaderTableViewCell.m in Sources */
,
2940AE9B1DE7FE17001164B0
/* OnlineLearningDetailViewController.m in Sources */
,
2986B9A31DE1D30700F4A1CF
/* PromotionChooseNavigationController.m in Sources */
,
...
...
@@ -3377,6 +3396,7 @@
29834EC01CDF5E4E001A484F
/* ScreeningFirstCollectionViewCell.m in Sources */
,
29834EC51CDF76C1001A484F
/* UserViewController.m in Sources */
,
29E2D3271DB88D8B00443170
/* CardOrderInformationReusableView.m in Sources */
,
8FEF03F31EA7543F00837A64
/* UIImage+Helper.m in Sources */
,
2971E9841DF69F9A00256567
/* CountDownLabel.m in Sources */
,
29CC51F81E8A032D009FBB6A
/* LuckyDrawMainViewController.m in Sources */
,
2962D06D1CD1A43A0058829D
/* ClientViewController.m in Sources */
,
...
...
Lighting/LearningCenter.storyboard
View file @
faa497b2
This diff is collapsed.
Click to expand it.
Tools/Category/UIImage+Helper.h
0 → 100644
View file @
faa497b2
//
// UIImage+Helper.h
// CXA
//
// Created by Xummer on 14-3-3.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface
UIImage
(
Helper
)
+
(
UIImage
*
)
getThumbnailImage
:(
UIImage
*
)
image
withMaxLen
:(
CGFloat
)
maxLen
;
-
(
UIImage
*
)
thumbnailWithMaxLen
:(
CGFloat
)
maxLen
;
-
(
UIImage
*
)
imageWithTintColor
:(
UIColor
*
)
tintColor
;
-
(
UIImage
*
)
imageWithGradientTintColor
:(
UIColor
*
)
tintColor
;
-
(
UIImage
*
)
imageWithTintColor
:(
UIColor
*
)
tintColor
blendMode
:(
CGBlendMode
)
blendMode
;
@end
@interface
UIImage
(
Color
)
+
(
UIImage
*
)
imageWithColor
:(
UIColor
*
)
color
;
+
(
UIImage
*
)
imageWithColor
:(
UIColor
*
)
color
andSize
:(
CGSize
)
size
;
+
(
UIImage
*
)
imageWithColor
:(
UIColor
*
)
color
andRect
:(
CGRect
)
rect
;
-
(
UIImage
*
)
greyScaleImage
;
/**
* 图片压缩到指定大小(具体看图片大小,过大的图片无法压缩到指定大小)
*
* @param kb 压缩后图片大小
*
* @return
*/
-
(
NSData
*
)
scaledToSpaceMaxSize
:(
NSInteger
)
kb
;
/**
* 压缩图片到指定高宽
*
* @param newSize 新的图片尺寸
*
* @return
*/
-
(
UIImage
*
)
scaledToSize
:(
CGSize
)
newSize
;
/**
* 按比例压缩图片至指定宽度
*
* @param newWidth 指定宽度
*
* @return
*/
-
(
UIImage
*
)
scaledToWidth
:(
NSInteger
)
newWidth
;
/**
* 获取图片缩略图
*
* @param sourceImage 原始图片
* @param size 生成尺寸
*
* @return 新的图片
*/
+
(
UIImage
*
)
imageCompressForSize
:(
UIImage
*
)
sourceImage
targetSize
:(
CGSize
)
size
;
@end
Tools/Category/UIImage+Helper.m
0 → 100644
View file @
faa497b2
//
// UIImage+Helper.m
// CXA
//
// Created by Xummer on 14-3-3.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import "UIImage+Helper.h"
@implementation
UIImage
(
Helper
)
// if newImage's width or heigth < 1, image will be cliped
+
(
UIImage
*
)
getThumbnailImage
:(
UIImage
*
)
image
withMaxLen
:(
CGFloat
)
maxLen
{
CGFloat
imageMaxLen
,
imageMinLen
;
BOOL
widthIsLarger
=
image
.
size
.
width
>
image
.
size
.
height
;
if
(
widthIsLarger
)
{
imageMaxLen
=
image
.
size
.
width
;
imageMinLen
=
image
.
size
.
height
;
}
else
{
imageMaxLen
=
image
.
size
.
height
;
imageMinLen
=
image
.
size
.
width
;
}
if
(
imageMaxLen
>
maxLen
)
{
CGFloat
scaleFloat
=
maxLen
/
imageMaxLen
;
CGFloat
newImgMinL
=
imageMinLen
*
scaleFloat
;
CGSize
size
;
if
(
newImgMinL
<
1
)
{
scaleFloat
=
1
/
imageMinLen
;
if
(
widthIsLarger
)
{
size
=
CGSizeMake
(
maxLen
,
image
.
size
.
height
*
scaleFloat
);
}
else
{
size
=
CGSizeMake
(
image
.
size
.
width
*
scaleFloat
,
maxLen
);
}
}
else
{
size
=
CGSizeMake
(
image
.
size
.
width
*
scaleFloat
,
image
.
size
.
height
*
scaleFloat
);
}
UIGraphicsBeginImageContext
(
size
);
CGContextRef
context
=
UIGraphicsGetCurrentContext
();
CGAffineTransform
transform
=
CGAffineTransformIdentity
;
transform
=
CGAffineTransformScale
(
transform
,
scaleFloat
,
scaleFloat
);
CGContextConcatCTM
(
context
,
transform
);
// Draw the image into the transformed context and return the image
[
image
drawAtPoint
:
CGPointMake
(
0
.
0
f
,
0
.
0
f
)];
UIImage
*
newimg
=
UIGraphicsGetImageFromCurrentImageContext
();
UIGraphicsEndImageContext
();
return
newimg
;
}
else
{
return
image
;
}
}
-
(
UIImage
*
)
thumbnailWithMaxLen
:(
CGFloat
)
maxLen
{
return
[[
self
class
]
getThumbnailImage
:
self
withMaxLen
:
maxLen
];
}
-
(
UIImage
*
)
imageWithTintColor
:(
UIColor
*
)
tintColor
{
return
[
self
imageWithTintColor
:
tintColor
blendMode
:
kCGBlendModeDestinationIn
];
}
-
(
UIImage
*
)
imageWithGradientTintColor
:(
UIColor
*
)
tintColor
{
return
[
self
imageWithTintColor
:
tintColor
blendMode
:
kCGBlendModeOverlay
];
}
-
(
UIImage
*
)
imageWithTintColor
:(
UIColor
*
)
tintColor
blendMode
:(
CGBlendMode
)
blendMode
{
//We want to keep alpha, set opaque to NO; Use 0.0f for scale to use the scale factor of the device’s main screen.
UIGraphicsBeginImageContextWithOptions
(
self
.
size
,
NO
,
0
.
0
f
);
[
tintColor
setFill
];
CGRect
bounds
=
CGRectMake
(
0
,
0
,
self
.
size
.
width
,
self
.
size
.
height
);
UIRectFill
(
bounds
);
//Draw the tinted image in context
[
self
drawInRect
:
bounds
blendMode
:
blendMode
alpha
:
1
.
0
f
];
if
(
blendMode
!=
kCGBlendModeDestinationIn
)
{
[
self
drawInRect
:
bounds
blendMode
:
kCGBlendModeDestinationIn
alpha
:
1
.
0
f
];
}
UIImage
*
tintedImage
=
UIGraphicsGetImageFromCurrentImageContext
();
UIGraphicsEndImageContext
();
return
tintedImage
;
}
@end
@implementation
UIImage
(
Color
)
typedef
enum
{
ALPHA
=
0
,
BLUE
=
1
,
GREEN
=
2
,
RED
=
3
}
PIXELS
;
+
(
UIImage
*
)
imageWithColor
:(
UIColor
*
)
color
{
CGRect
rect
=
CGRectMake
(
0
.
0
f
,
0
.
0
f
,
1
.
0
f
,
1
.
0
f
);
return
[[
self
class
]
imageWithColor
:
color
andRect
:
rect
];
}
+
(
UIImage
*
)
imageWithColor
:(
UIColor
*
)
color
andRect
:(
CGRect
)
rect
{
UIGraphicsBeginImageContext
(
rect
.
size
);
CGContextRef
context
=
UIGraphicsGetCurrentContext
();
CGContextSetFillColorWithColor
(
context
,[
color
CGColor
]);
CGContextFillRect
(
context
,
rect
);
UIImage
*
image
=
UIGraphicsGetImageFromCurrentImageContext
();
UIGraphicsEndImageContext
();
return
image
;
}
+
(
UIImage
*
)
imageWithColor
:(
UIColor
*
)
color
andSize
:(
CGSize
)
size
{
return
[[
self
class
]
imageWithColor
:
color
andRect
:(
CGRect
){
.
origin
=
CGPointZero
,
.
size
=
size
}];
}
-
(
UIImage
*
)
greyScaleImage
{
CGSize
size
=
[
self
size
];
int
width
=
size
.
width
;
int
height
=
size
.
height
;
// the pixels will be painted to this array
uint32_t
*
pixels
=
(
uint32_t
*
)
malloc
(
width
*
height
*
sizeof
(
uint32_t
));
// clear the pixels so any transparency is preserved
memset
(
pixels
,
0
,
width
*
height
*
sizeof
(
uint32_t
));
CGColorSpaceRef
colorSpace
=
CGColorSpaceCreateDeviceRGB
();
// create a context with RGBA pixels
CGContextRef
context
=
CGBitmapContextCreate
(
pixels
,
width
,
height
,
8
,
width
*
sizeof
(
uint32_t
),
colorSpace
,
kCGBitmapByteOrder32Little
|
kCGImageAlphaPremultipliedLast
);
// paint the bitmap to our context which will fill in the pixels array
CGContextDrawImage
(
context
,
CGRectMake
(
0
,
0
,
width
,
height
),
[
self
CGImage
]);
for
(
int
y
=
0
;
y
<
height
;
y
++
)
{
for
(
int
x
=
0
;
x
<
width
;
x
++
)
{
uint8_t
*
rgbaPixel
=
(
uint8_t
*
)
&
pixels
[
y
*
width
+
x
];
// convert to grayscale using recommended method: http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
uint32_t
gray
=
0
.
3
*
rgbaPixel
[
RED
]
+
0
.
59
*
rgbaPixel
[
GREEN
]
+
0
.
11
*
rgbaPixel
[
BLUE
];
// set the pixels to gray
rgbaPixel
[
RED
]
=
gray
;
rgbaPixel
[
GREEN
]
=
gray
;
rgbaPixel
[
BLUE
]
=
gray
;
}
}
// create a new CGImageRef from our context with the modified pixels
CGImageRef
image
=
CGBitmapContextCreateImage
(
context
);
// we're done with the context, color space, and pixels
CGContextRelease
(
context
);
CGColorSpaceRelease
(
colorSpace
);
free
(
pixels
);
// make a new UIImage to return
UIImage
*
resultUIImage
=
[
UIImage
imageWithCGImage
:
image
];
// we're done with image now too
CGImageRelease
(
image
);
return
resultUIImage
;
}
-
(
NSData
*
)
scaledToSpaceMaxSize
:
(
NSInteger
)
kb
{
//压缩到100kb以内
CGFloat
compression
=
0
.
5
f
;
CGFloat
maxCompression
=
0
.
1
f
;
NSUInteger
maxlength
=
kb
*
1024
;
NSData
*
imgData
=
UIImageJPEGRepresentation
(
self
,
compression
);
// CLog(@"处理之前的大小--->%lukB",(unsigned long)imgData.length/1024);
while
([
imgData
length
]
>
maxlength
&&
compression
>
maxCompression
)
{
compression
-=
0
.
1
;
imgData
=
UIImageJPEGRepresentation
(
self
,
compression
);
}
// CLog(@"处理之后的大小--->%lukB",(unsigned long)imgData.length/1024);
return
imgData
;
}
-
(
UIImage
*
)
scaledToSize
:
(
CGSize
)
newSize
{
UIGraphicsBeginImageContextWithOptions
(
newSize
,
YES
,
0
);
[
self
drawInRect
:
CGRectMake
(
0
,
0
,
newSize
.
width
,
newSize
.
height
)];
UIImage
*
scaledImage
=
UIGraphicsGetImageFromCurrentImageContext
();
UIGraphicsEndImageContext
();
return
scaledImage
;
}
-
(
UIImage
*
)
scaledToWidth
:
(
NSInteger
)
newWidth
{
CGSize
newSize
=
CGSizeMake
(
newWidth
,
newWidth
/
self
.
size
.
width
*
self
.
size
.
height
);
UIGraphicsBeginImageContextWithOptions
(
newSize
,
YES
,
0
);
[
self
drawInRect
:
CGRectMake
(
0
,
0
,
newSize
.
width
,
newSize
.
height
)];
UIImage
*
scaledImage
=
UIGraphicsGetImageFromCurrentImageContext
();
UIGraphicsEndImageContext
();
return
scaledImage
;
}
#pragma mark - 获取缩略图
+
(
UIImage
*
)
imageCompressForSize
:
(
UIImage
*
)
sourceImage
targetSize
:
(
CGSize
)
size
{
UIImage
*
newImage
=
nil
;
CGSize
imageSize
=
sourceImage
.
size
;
CGFloat
width
=
imageSize
.
width
;
CGFloat
height
=
imageSize
.
height
;
CGFloat
targetWidth
=
size
.
width
;
CGFloat
targetHeight
=
size
.
height
;
CGFloat
scaleFactor
=
0
.
0
;
CGFloat
scaledWidth
=
targetWidth
;
CGFloat
scaledHeight
=
targetHeight
;
CGPoint
thumbnailPoint
=
CGPointMake
(
0
.
0
,
0
.
0
);
if
(
CGSizeEqualToSize
(
imageSize
,
size
)
==
NO
){
CGFloat
widthFactor
=
targetWidth
/
width
;
CGFloat
heightFactor
=
targetHeight
/
height
;
if
(
widthFactor
>
heightFactor
){
scaleFactor
=
widthFactor
;
}
else
{
scaleFactor
=
heightFactor
;
}
scaledWidth
=
width
*
scaleFactor
;
scaledHeight
=
height
*
scaleFactor
;
if
(
widthFactor
>
heightFactor
){
thumbnailPoint
.
y
=
(
targetHeight
-
scaledHeight
)
*
0
.
5
;
}
else
if
(
widthFactor
<
heightFactor
){
thumbnailPoint
.
x
=
(
targetWidth
-
scaledWidth
)
*
0
.
5
;
}
}
UIGraphicsBeginImageContextWithOptions
(
size
,
NO
,
3
.
0
);
CGRect
thumbnailRect
=
CGRectZero
;
thumbnailRect
.
origin
=
thumbnailPoint
;
thumbnailRect
.
size
.
width
=
scaledWidth
;
thumbnailRect
.
size
.
height
=
scaledHeight
;
[
sourceImage
drawInRect
:
thumbnailRect
];
newImage
=
UIGraphicsGetImageFromCurrentImageContext
();
if
(
newImage
==
nil
){
NSLog
(
@"scale image fail"
);
}
UIGraphicsEndImageContext
();
return
newImage
;
}
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment