增加激活编辑状态的block

This commit is contained in:
BearXR
2020-01-20 16:20:36 +08:00
parent ea8b104c84
commit 327c14148a
2 changed files with 24 additions and 2 deletions

View File

@@ -12,7 +12,14 @@
#import "CRBoxInputCell.h"
@class CRBoxInputView;
typedef NS_ENUM(NSInteger, CRTextEditStatus) {
CRTextEditStatus_Idle,
CRTextEditStatus_BeginEdit,
CRTextEditStatus_EndEdit,
};
typedef void(^TextDidChangeblock)(NSString * _Nullable text, BOOL isFinished);
typedef void(^TextEditStatusChangeblock)(CRTextEditStatus editStatus);
@interface CRBoxInputView : UIView
@@ -70,6 +77,7 @@ typedef void(^TextDidChangeblock)(NSString * _Nullable text, BOOL isFinished);
@property (strong, nonatomic) NSString * _Nullable placeholderText;
@property (copy, nonatomic) TextDidChangeblock _Nullable textDidChangeblock;
@property (copy, nonatomic) TextEditStatusChangeblock _Nullable textEditStatusChangeblock;
@property (strong, nonatomic) CRBoxFlowLayout * _Nullable boxFlowLayout;
@property (strong, nonatomic) CRBoxInputCellProperty * _Nullable customCellProperty;
@property (strong, nonatomic, readonly) NSString * _Nullable textValue;

View File

@@ -158,22 +158,36 @@ typedef NS_ENUM(NSInteger, CRBoxTextChangeType) {
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
_ifNeedBeginEdit = YES;
if (self.textEditStatusChangeblock) {
self.textEditStatusChangeblock(CRTextEditStatus_BeginEdit);
}
[self.mainCollectionView reloadData];
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
_ifNeedBeginEdit = NO;
if (self.textEditStatusChangeblock) {
self.textEditStatusChangeblock(CRTextEditStatus_EndEdit);
}
[self.mainCollectionView reloadData];
}
#pragma mark - TextViewEdit
- (void)beginEdit{
[self.textView becomeFirstResponder];
if (![self.textView isFirstResponder]) {
[self.textView becomeFirstResponder];
}
}
- (void)endEdit{
[self.textView resignFirstResponder];
if ([self.textView isFirstResponder]) {
[self.textView resignFirstResponder];
}
}
- (void)clearAll