How to make a UIView Scrollable?

梦想与她 提交于 2019-12-08 03:49:27

问题


Hi there I have a UIView with a bunch of UITextfields. My problem is that my UITextfields are present from the top to the bottom of my screen. So when the keyboard pops up, it covers half the screen and consequently the UITextfields below...What can I do so that all the fields can be edited by simmply scrolling when the keyboard is visible?


回答1:


You need to embed your UIView into a UIScrollView and then change the size of the UIScrollView when the keyboard pops up.




回答2:


Just give the view a new transform that moves it up. Eg.

[myView setTransform:CGAffineTransformMakeTranslation(0, -keyboardSize.height)];

Thats also animatable, just give it the same animation values as the keyboards and it will look perfect.




回答3:


This solution is from XCode 5, iOS 7.0 and Storyboards. It worked for me quite well.

http://www.youtube.com/watch?v=4oCWxHLBQ-A



来源:https://stackoverflow.com/questions/5608761/how-to-make-a-uiview-scrollable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!