由于刚用RAC库, 不知如何经过signals监听枚举类型UIKtyboardType
而后求助强大的Stack Overflow
终于两个小时后一位国际友人回答了这个问题,通过测试正确感谢.测试
代码以下.h
文件atom
#import <UIKit/UIKit.h> @interface XBXMLoginTextField : UIView @property (nonatomic, assign) UIKeyboardType keyboardType; @end
.m
文件- (instancetype)init { if (self = [super init]) { [RACObserve(self, keyboardType) subscribeNext:^(UIKeyboardType x) { }]; } return self; }
这种作法编译都通不过报错Incompatible block pointer types sending 'void (^)(UIKeyboardType)' to parameter of type 'void (^ _Nonnull)(id _Nullable __strong)'
code
[RACObserve(self, keyboardType) subscribeNext:^(NSNumber *keyboardType) { NSLog(@"%ld", (long)keyboardType.integerValue); // Or any other user of keyboardType.integerValue, such as: if (keyboardType.integerValue == UIKeyboardTypeURL) { // Do stuff. } }];
原文连接