由於剛用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. } }];
原文連接