0

UITextView編集中にスクロール可能にする方法を知りたいですか? ユーザーが編集したい場合、キーボードは表示されますが、UITextViewスクロールできなくなります。したがって、キーボードの背後にあるすべてのテキストは表示されません。

4

2 に答える 2

4

キーボードのテキストビューのサイズを縮小できます

-(void)textViewDidBeginEditing:(UITextView *)textView
{
    CGRect frame = txtAddNote.frame;
    frame.size.height = 150; //Decrease your textView height at this time
    txtAddNote.frame = frame;
}
-(IBAction)DoneBarBtnPress:(id)sender
{
    CGRect frame = txtAddNote.frame;
    frame.size.height = 212; //Original Size of textView
    txtAddNote.frame = frame;

    //Keyboard dismiss 
    [self.view endEditing:YES];
}
于 2012-12-04T11:42:48.003 に答える
1

UITextViewこのように編集を開始するときにビューをスクロールするだけです..

-(void)textViewDidBeginEditing:(UITextView *)textView
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
    self.view.frame = CGRectMake(self.view.frame.origin.x, -160, self.view.frame.size.width, self.view.frame.size.height);
    [UIView commitAnimations];

}

そしてendEditingでは、以下のようにデフォルト画面を設定するだけです..

-(void)textViewDidEndEditing:(UITextView *)textView
{
    [textView resignFirstResponder];
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    self.view.frame = CGRectMake(self.view.frame.origin.x, 0, self.view.frame.size.width, self.view.frame.size.height);
    [UIView commitAnimations];
}

アップデート

ここでは、要件に応じて、ビューでフレームを設定します。以下のコードを参照してください

-(void)textViewDidBeginEditing:(UITextView *)textView
    {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.3];
         [yourTextView setFrame:CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y,self.view.‌​frame.size.width,self.view.frame.size.height - 160)];
        [UIView commitAnimations];

    }

-(void)textViewDidEndEditing:(UITextView *)textView
    {
        [textView resignFirstResponder];
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.3];
        [yourTextView setFrame:self.view];
        [UIView commitAnimations];
    }
于 2012-12-04T11:08:59.073 に答える