iOS可以给类设置属性
iOS可以设置是否禁用第三方键盘,以及针对个别页面是否禁用第三方键盘
//为类别设置属性
@property (nonatomic,assign,class) BOOL useSystemKeyBoard;
+(void)setUseSystemKeyBoard:(BOOL)useSystemKeyBoard{
objc_setAssociatedObject(self, @selector(useSystemKeyBoard), @(useSystemKeyBoard), OBJC_ASSOCIATION_ASSIGN);
}
+(BOOL)useSystemKeyBoard{
NSNumber *useSystemKeyBoard =objc_getAssociatedObject(self, @selector(useSystemKeyBoard));
return [useSystemKeyBoard boolValue];
}
//是否允许使用第三方键盘
- (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier NS_AVAILABLE_IOS(8_0)
{
if ([extensionPointIdentifier isEqualToString:@"com.apple.keyboard-service"]) {
if (UITextField.useSystemKeyBoard) {
return NO;
}
}
return YES;
}
//设置某个键盘不允许使用第三方键盘
- (void)textFieldDidBeginEditing:(UITextField *)textField{
if (textField == self.topTxtFld) {
UITextField.useSystemKeyBoard = YES;
}else{
UITextField.useSystemKeyBoard = NO;
}
}
- (void)textFieldDidEndEditing:(UITextField *)textField{
UITextField.useSystemKeyBoard = NO;
}
© 版权声明
文章版权归作者所有,未经允许请勿转载。如内容涉嫌侵权,请在本页底部进入<联系我们>进行举报投诉!
THE END







![效率神器:文件夹/程序/网址/注册表路径快速打开/跳转 QuickJump 3.0[2022.11.24] - 宋马](https://pic.songma.com/blogimg/20250421/d1bb99d3809a410d915a1b0de7b4a8ae.jpg)














暂无评论内容