当键盘显示时,UiTextView可以显示选择或光标。 我想隐藏键盘,并保持显示选择或光标的UiTextView(我在UiTextView下面显示一个格式设置面板,并且希望通过格式面板修改textview的选择格式,所以保持选择textview显示在需要)。uitextview无法在隐藏键盘后显示选择或光标
感谢〜
如果要隐藏键盘不仅没有光标当键盘显示时,UiTextView可以显示选择或光标。 我想隐藏键盘,并保持显示选择或光标的UiTextView(我在UiTextView下面显示一个格式设置面板,并且希望通过格式面板修改textview的选择格式,所以保持选择textview显示在需要)。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
}
}
}
斯威夫特& 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
}
}
}
感谢您的回答。但是“if([[keyboard description] hasPrefix:@”
是您的解决方案是工作在IOS 10? – KKRocks
让窗口= UIApplication.shared.windows \t \t为窗口中的窗口{ \t \t \t如果(** NSStringFromClass(window.classForCoder)== “UIRemoteKeyboardWindow” **){ \t \t \t \t让子视图=窗口。子视图 \t \t \t \t如果(subViews.count> 0){ \t \t \t \t \t子视图[0]。阿尔法= 0 \t \t \t \t} \t \t \t} \t \t} --------------------这确实工作!非常感谢。 – Zero
u能阐述更乌尔问题.....? –
textView是可编辑的。软键盘显示单击textView时,textView可以显示选择和光标。当“textview resignFirstResponder”被调用时,键盘解散,文本视图结束编辑模式并停止显示选择或光标,但我需要的是textview在键盘解除后仍然显示选择或光标。 – Zero