0

What I have is 15 text field and because of which I can't set them in one ViewController. I added 15 textfield to the scrollview . But scroll view goes up on removing finger from the screen.

Any idea how to stick to down when scrolled to down?

4

4 回答 4

2

在你的ViewWillApear设置你UIScrollview contentSize喜欢: -

-(void)viewWillAppear:(BOOL)animated
{

     srcScrollView.contentSize = CGSizeMake(320, 500);
    [super viewWillAppear:YES];
}

你的 TextFiled 代表看起来像:-

-(void)textFieldDidBeginEditing:(FMTextField *)textField
{
    [srcScrollView setContentOffset:CGPointMake(0,textField.center.y-140) animated:YES];


}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];

     [srcScrollView setContentOffset:CGPointMake(0,0) animated:YES];


    return YES;
}
于 2013-03-05T07:50:15.963 回答
0

您的 contentSize 似乎不足以显示整个内容。设置contensize如下

//Assuming you have a reference to the 15th textField 

CGRect textField15Frame = self.textField15.frame;

CGSize contentSize = self.scrollView.contentSize;
contentSize.height = textField15Frame.origin.y+textField15.size.height+5.0f;

[self.scrollView setContentSize:contentSize];
于 2013-03-05T08:46:29.313 回答
0

你必须正确设置contentSize你的滚动视图。在您的情况下,您只需将内容高度设置为:

lastTextField.frame.origin.y + lastTextField.frame.size.height + 10

其中 10 是您想要的下边距。

于 2013-03-05T07:50:28.813 回答
0

下面解决了问题...

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    [self.scrollView setContentSize:CGSizeMake(320, 1200)];
}
于 2013-03-05T07:55:14.533 回答