[英]Disable scrolling when native keyboard is visiable on mobile
My layout breaks when the user clicks a input field or a selectbox and the native iphone keyboard gets visible. 当用户单击输入字段或选择框并且本机iphone键盘可见时,我的布局中断。 I thought it might be a good idea if you could disable scroll when the native keyboard is visible.
我认为如果可以在显示本机键盘时禁用滚动,则可能是一个好主意。 Could javascript achieve that?
javascript可以实现吗?
Thanks in advance 提前致谢
You can achieve this by register for recieving the notifications on UIKeyboardDidShowNotification
and UIKeyboardDidHideNotification
in the viewDidLoad
您可以通过在
viewDidLoad
注册接收UIKeyboardDidShowNotification
和UIKeyboardDidHideNotification
上的通知来实现
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(keyboardWasShown)
name: UIKeyboardDidShowNotification
object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(keyboardWasHidden)
name: UIKeyboardDidHideNotification
object: nil];
And implement the selectors as below 并实现如下选择器
When the keyboard is about to show you will get a call in this 当键盘即将显示时,您将在此接到一个电话
- (void) keyboardWasShown
{
// Code to disable the scrolling of your scrollview
}
And when the keyboard is about to hide you will get a call here 当键盘要隐藏时,您会在这里接到电话
- (void) keyboardWasHidden
{
// Code to enable the scrolling of your scrollview
}
Glad if i can see this helps you in someways. 很高兴我能看到这对您有所帮助。 Happy day.
愉快的一天。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.