隐藏键盘后uitextview无法显示选择或光标
uitextview can not display selection or cursor after hide the keyboard
当键盘显示时,UiTextView 可以显示选择或光标。
我想隐藏键盘并保持 UiTextView 显示选择或光标(我在 UiTextView 下方显示格式设置面板,并希望通过格式面板修改文本视图的选择格式,因此保持文本视图的选择显示在需要).
谢谢~
如果你只想隐藏键盘而不是光标。试试下面的代码:
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
}
}
}
Swift & 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
}
}
}
当键盘显示时,UiTextView 可以显示选择或光标。 我想隐藏键盘并保持 UiTextView 显示选择或光标(我在 UiTextView 下方显示格式设置面板,并希望通过格式面板修改文本视图的选择格式,因此保持文本视图的选择显示在需要).
谢谢~
如果你只想隐藏键盘而不是光标。试试下面的代码:
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
}
}
}
Swift & 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
}
}
}