简体   繁体   English

Swift:输入文字时,UIScrollView / UITextView会跳起来

[英]Swift: UIScrollView/UITextView jumps up when entering text

I'm using a UITextView inside a UIView that's inside a UIScrollView. 我在UIScrollView内的UIView中使用UITextView。 Whenever I launch the app for the first time and attempt to type something into the UITextView, the view jumps up. 每当我第一次启动该应用程序并尝试在UITextView中键入内容时,视图就会跳起来。 Also, when the view is first visible, the textview is not completely visible. 同样,当视图首次可见时,textview也不是完全可见的。

I've attempted to pin the UIView to the top layout guide. 我试图将UIView固定在顶部布局指南中。 It stops that issue from occurring, however when a large body of text is entered in the UITextView, I'm unable to scroll down to view the song thumbnail. 它阻止了该问题的发生,但是,当在UITextView中输入大量文本时,我无法向下滚动以查看歌曲缩略图。

What could be done to fix this? 该如何解决?

在此处输入图片说明

This wasn't necessarily the fix I wanted, but I realised UIScrollView is sometimes a little tricky to overcome. 这不一定是我想要的解决方法,但是我意识到UIScrollView有时需要克服一些技巧。

I removed the UIView that held the UITextView and the album image and placed them directly into the UIScrollView. 我删除了保存UITextView和相册图像的UIView,并将它们直接放入UIScrollView中。 Then clipped the bottom of the UIScrollView to the bottom layout guide. 然后将UIScrollView的底部剪切到底部布局指南。

This stopped the jitter issue when typing but it's still not perfect. 这样就消除了打字时的抖动问题,但仍然不够完美。

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

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