ReactiveCocoa / ReactiveObjC

The 2.x ReactiveCocoa Objective-C API: Streams of values over time
MIT License
2.6k stars 496 forks source link

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

Open jackson0122 opened 5 years ago

jackson0122 commented 5 years ago

_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 )