隐藏键盘后,uitextview无法显示选择或光标

时间:2017-04-27 03:41:23

标签: ios keyboard uitextview selection

当键盘显示时,UiTextView可以显示选择或光标。 我想隐藏键盘并保持UiTextView显示选择或光标(我在UiTextView下面显示格式设置面板,并希望通过格式面板修改textview选择的格式,因此保持选择textview显示需要)。

感谢〜

1 个答案:

答案 0 :(得分:0)

如果你想隐藏键盘而不是光标。请尝试以下代码:

for (UIWindow *keyboardWindow in [[UIApplication sharedApplication] windows]) {
        for (UIView *keyboard in [keyboardWindow subviews]) {
            if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES) {

                keyboard.alpha = 0;// here change keyboard alpha
            }
        }
}

斯威夫特&amp; IOS 10

    let windows = UIApplication.shared.windows for window in windows { 
      if (NSStringFromClass(window.classForCoder) == "UIRemoteKeyboardWindow") { 
        let subViews = window.subviews if (subViews.count > 0) { subViews[0].alpha = 0 
      } 
    } 
 }