代码片段ios 常用知识点详解

ios 指定页面禁用第三方键盘,使用系统的键盘

2021-07-13  本文已影响0人  缘來諟夢
//强制使用系统键盘
- (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier{
    if ([[self getCurrentVC] isKindOfClass:[CLSLoginViewController class]]) {
        if ([extensionPointIdentifier isEqualToString:@"com.apple.keyboard-service"]) {
            return NO;
        }
    }
    return YES;
}
- (UIViewController *)getCurrentVC{
    UIViewController *result = nil;
    UIWindow * window = [[UIApplication sharedApplication] keyWindow];
    if (window.windowLevel != UIWindowLevelNormal){
        NSArray *windows = [[UIApplication sharedApplication] windows];
        for(UIWindow * tmpWin in windows){
            if (tmpWin.windowLevel == UIWindowLevelNormal){
                window = tmpWin;
                break;
            }
        }
    }
    UIView *frontView = [[window subviews] objectAtIndex:0];
    id nextResponder = [frontView nextResponder];
    if ([nextResponder isKindOfClass:[UIViewController class]])
        result = nextResponder;
    else
        result = window.rootViewController;
    return result;
}

上一篇下一篇

猜你喜欢

热点阅读