How to make an UITextView scrollable when the keyboard appears?

后端 未结 2 1587
忘掉有多难
忘掉有多难 2021-01-26 13:49

I would like to know how I can make my UITextView scrollable when it\'s being edited ? When the user wants to edit it, the keyboard shows but then the UITextV

2条回答
  •  清酒与你
    2021-01-26 14:31

    You can reduce sizeOf you textView on keyBoard appear

    -(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];
    }
    

提交回复
热议问题