Skip to content

用rac_signalForSelector 代替textField:shouldChangeCharactersInRange:replacementString :时无法输入 #155

Open
@jackson0122

Description

@jackson0122

_textField = [UITextField new];
_textField.frame = CGRectMake(50, 50, 200, 30);
_textField.backgroundColor = [UIColor cyanColor];
_textField.delegate = self;
[self.view addSubview:_textField];

[[self rac_signalForSelector:@selector(textField:shouldChangeCharactersInRange:replacementString:) fromProtocol:@protocol(UITextFieldDelegate)] subscribeNext:^(RACTuple *x) {
    NSLog(@"_____%@",x);
}];

output:
2019-03-23 17:49:59.611420+0800 LLKit[18454:188204] _____<RACTuple: 0x600000314290> (
"<UITextField: 0x7f8601032400; frame = (50 50; 200 30); text = ''; opaque = NO; gestureRecognizers = <NSArray: 0x600000f4e3a0>; layer = <CALayer: 0x600000144760>>",
"NSRange: {0, 0}",
S
)
2019-03-23 17:49:59.777225+0800 LLKit[18454:188204] _____<RACTuple: 0x60000030add0> (
"<UITextField: 0x7f8601032400; frame = (50 50; 200 30); text = ''; opaque = NO; gestureRecognizers = <NSArray: 0x600000f4e3a0>; layer = <CALayer: 0x600000144760>>",
"NSRange: {0, 0}",
S
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions