简体   繁体   English

iOS输入中的固定容器焦点错误

[英]iOS input in fixed container focus bug

I am having a strange bug in ios safari where a position:fixed sidebar with an input in it which allows a user to perform a search query. 我在Safari Safari浏览器中遇到一个奇怪的错误,该错误中有一个position:fixed侧边栏,其中有一个输入,允许用户执行搜索查询。 Everything is fine when to scrollTop of the page is 0 (no scrolling occurred, top of page). 当scrollTop页面顶部为0时,一切都很好(没有滚动发生,页面顶部)。 At this state the input is focusable and the user can enter stuff in the input. 在这种状态下,输入是可聚焦的,并且用户可以在输入中输入内容。 However when the user scrolls a few pixels down the input is no longer focusable and the user can not input anything, nor does the keyboard show. 但是,当用户向下滚动几个像素时,输入将不再可聚焦,并且用户无法输入任何内容,键盘也不会显示。

Anyone else ever encountered this bug or know a fix/hack that could solve this? 其他人是否曾遇到此错误或知道可以解决此问题的修复程序/黑客?

Thanks, 谢谢,

K. K.

This is not bug, when you tap the textFiled it becomes FirstResponder and you can enter text in it using keyboard. 这不是错误,当您单击textFiled时,它将变为FirstResponder,并且可以使用键盘在其中输入文本。 When you scroll the scrollView, textField will resign as FirstResponder and scrollview will become FirstResponder. 滚动scrollView时,textField将退出为FirstResponder,scrollview将成为FirstResponder。 So now you want be able edit text in textfield unless you tap it again. 因此,现在您希望能够在文本字段中编辑文本,除非再次单击它。

Regarding keyboard not showing up, this is because when textfield resigns as FirstResponder it will call textFieldShouldEndEditing: delegate method and you might be returning YES in this method. 关于键盘未显示,这是因为当文本字段退出为FirstResponder时,它将调用textFieldShouldEndEditing:委托方法,并且您可能在此方法中返回YES。

I changed all fixed containers to absolute positioned containers and now it works. 我将所有固定容器更改为绝对定位的容器,现在可以使用了。 Guess position:fixed still has some side effects in ios safari. 猜测位置:固定在ios Safari中仍然有一些副作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM