aot*_*n16 4 ios uitextinput swift swift2
我想在Swift 2中获得UITextInputMode但UITextInputMode.activeInputModes()崩溃了.
let x = UITextInputMode.activeInputModes() // crash here
for t in x {
print(t)
}
Run Code Online (Sandbox Code Playgroud)
Mol*_*nda 10
通过使用Objective-C桥,我能够解决这个bug.
Bridge.h
#ifndef Bridge_h
#define Bridge_h
#import "Kludge.h"
#endif
Run Code Online (Sandbox Code Playgroud)
Kludge.h
#ifndef Kludge_h
#define Kludge_h
#import <UIKit/UITextInput.h>
@interface Kludge : NSObject
+ (NSArray<UITextInputMode *> *)activeInputModes;
@end
#endif
Run Code Online (Sandbox Code Playgroud)
Kludge.m
#import "Kludge.h"
@implementation Kludge
+ (NSArray<UITextInputMode *> *)activeInputModes {
return (NSArray<UITextInputMode *> *)[UITextInputMode activeInputModes];
}
@end
Run Code Online (Sandbox Code Playgroud)
从Swift,您现在可以调用Kludge.activeInputModes()并获得正确的结果.
| 归档时间: |
|
| 查看次数: |
739 次 |
| 最近记录: |