123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- //
- // XYModifyInputTextTableViewCell.m
- // Timi
- //
- // Created by gy on 2021/3/4.
- //
- #import "XYModifyInputTextTableViewCell.h"
- #import "UITextView+KCPlaceHolder.h"
- #import "XYModifyUserInfoListModel.h"
- @interface XYModifyInputTextTableViewCell ()<UITextViewDelegate>
- @property (nonatomic, strong) UITextView *textView;
- @end
- @implementation XYModifyInputTextTableViewCell
- #pragma mark - Public Method
- + (instancetype)cellWithTableView:(UITableView *)tableView {
- static NSString * const cellId = @"XYModifyInputTextTableViewCell";
- XYModifyInputTextTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
- if (cell == nil) {
- cell = [[XYModifyInputTextTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return cell;
- }
- - (void)configureModel:(XYModifyUserInfoListModel *)model {
- self.textView.text = model.itemValue;
- }
- #pragma mark - 初始化
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
-
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- // 初始化
- [self _setup];
- }
- return self;
- }
- #pragma mark - 事件处理Or辅助方法
- - (void)saveAction {
- if (StringIsEmpty(self.textView.text)) {
- [SVProgressHUD showInfoWithStatus:kLocalizedString(@"不能为空")];
- return;
- }
-
- [self.textView resignFirstResponder];
-
- [self.delegate XYModifyInputTextTableViewCellAction:self.textView.text];
-
- }
- #pragma mark - Private Method
- - (void)_setup{
- self.backgroundColor = Color_White;
- [self textView];
- }
- - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
- if ([text isEqualToString:@"\n"]){
- [self saveAction];
- return NO;
- }
- return YES;
- }
- - (UITextView *)textView{
- if (_textView == nil) {
- _textView = [UITextView new];
- _textView.kc_placeHolder = kLocalizedString(@"填写个性签名~");
- _textView.kc_maxWordInput = [NSNumber numberWithInt:1000];
- _textView.kc_placeHolderColor = UIColorFromRGB(0xCCCCCC);
- _textView.kc_placeHolderFont = [UIFont fontWithName:kPFSCFont size:12];
- _textView.backgroundColor = [UIColor clearColor];
- _textView.returnKeyType = UIReturnKeySend;
- _textView.delegate = self ;
- _textView.textColor = UIColorFromRGB(0x303133);
- _textView.font = RegularFont(12);
- _textView.returnKeyType = UIReturnKeyDone;
- [self.contentView addSubview:_textView];
- [_textView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView.mas_left).offset(20);
- make.right.equalTo(self.contentView.mas_right).offset(-20);
- make.top.equalTo(self.contentView.mas_top).offset(10);
- make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
- }];
- }
- return _textView ;
- }
- - (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
|