1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// ContentTableViewCell.m
// Lighting
//
// Created by 曹云霄 on 2016/12/9.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "ContentTableViewCell.h"
#import "STEmojiKeyboard.h"
@implementation ContentTableViewCell
- (void)awakeFromNib {
[super awakeFromNib];
[self setUpToolView];
}
#pragma mark - ToolView
- (void)setUpToolView {
KeyBoardAccessoryView *toolView = [[KeyBoardAccessoryView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 44)];
toolView.delegate = self;
self.contentTextView.inputAccessoryView = toolView;
self.contentTextView.m_placeHolder = @"请输入内容";
}
#pragma mark - Click
- (void)extensionButtonClick:(UIButton *)sender {
switch (sender.tag) {
case Camera: {
if ([self.delgate respondsToSelector:@selector(showCameraAction)]) {
[self.delgate showCameraAction];
}
} break;
case PhotoAlbum: {
if ([self.delgate respondsToSelector:@selector(showPhotoAlbumAction)]) {
[self.delgate showPhotoAlbumAction];
}
} break;
case Emoji: {
sender.selected = !sender.selected;
if (sender.selected) {
[[STEmojiKeyboard keyboard] setTextView:self.contentTextView];
} else {
[self.contentTextView setInputView:nil];
}
[self.contentTextView reloadInputViews];
[self.contentTextView becomeFirstResponder];
} break;
default:
break;
}
}
#pragma mark - <UITextViewDelegate>
- (void)textViewDidEndEditing:(UITextView *)textView {
self.heightConstraint.constant = [self calculateStudyIntroductionHeight:textView.text];
if ([self.delgate respondsToSelector:@selector(refreshHeight:)]) {
[self.delgate refreshHeight:self.contentTextView.height];
}
}
#pragma mark - 计算高度
- (CGFloat)calculateStudyIntroductionHeight:(NSString *)content {
return [content heightWithFontSize:14 width:ScreenWidth - 40] + 20;
}
@end