当键盘显示时,UiTextView可以显示选择或光标。 我想隐藏键盘并保持UiTextView显示选择或光标(我在UiTextView下面显示格式设置面板,并希望通过格式面板修改textview选择的格式,因此保持选择textview显示需要)。
感谢〜
答案 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
}
}
}