开发者

How to make a UIView Scrollable?

开发者 https://www.devze.com 2023-02-23 01:47 出处:网络
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 ha

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?

How to make a UIView Scrollable?

How to make a UIView Scrollable?


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


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号