I have many textfields in my Application which are in a scrollview.
What i need is when user touches on a textfield,
scrollview should scroll in such a way, so that that textfield should not be behind the keyboard.
该链接完整地说明了所提问题
您可以使用方法- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
在UIScrollView中设置(void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
,这应该滚动到您给定的点的偏移量,您需要通过代码找出偏移量
I've written a pretty straightforward tutorial on doing this, it mimics as much as possible the behavior of Apple own applications, if it can be of any help:
Maybe you could set the text fields' delegates to self, and then adopt the UITextFielDelegate protocol for the class, and then in this method:
- (void)textFieldDidBeginEditing:(UITextField *)textField
Make the scroll view scroll down enough so that you can see the text field.. I don't know how to make the scrollview scroll down though.
Here is a free library for keyboard handling http://www.codeproject.com/Tips/509810/Keyboard-Handling-in-iPhone-Applications . You need write just one line of code:
[AutoScroller addAutoScrollTo:scrollView];
Dont confuse with name AutoScroller. Purpose is same what you asked.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.