我想知道在编辑时如何滚动我的UITextView
?当用户想要编辑它时,键盘显示,但UITextView
不再滚动。所以键盘后面的所有文本都不可见。如何在键盘出现时使UITextView可滚动?
回答
您可以减少整型尺寸你的TextView在键盘出现
-(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];
}
只是滚动视图时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];
}
UPDATE
这里有您的要求我们设置框架与我们的看法见波纹管代码
-(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];
}
这些动画使用块更具可读性。 – dasdom
不,这根本不起作用。我有一个工具栏在顶部,有一个'后退'按钮和一个'完成'按钮。然后我有一个UITextView几乎和视图本身一样大。所以当我做你的方法时,视图只是向上移动,然后工具栏不再可达。完成后,这不会使我的UITextView可滚动,而我选择了IB中的可滚动选项,并且可以在不编辑它时滚动它。 –
@frénésie只需添加此行并测试它。[yourTextView setScrollsToTop:YES]; –
- 1. 如何在键盘出现时使android视图滚动?
- 2. 键盘显示时UITextView不会滚动
- 3. 键盘出现时滚动组tableView
- 4. Swift:当出现键盘时滚动UITableView
- 5. 滚动条时,键盘会出现
- 6. 如何在键盘出现时向上滚动视图?
- 7. 如何在目标c中出现键盘时滚动视图?
- 8. uitextview键盘出现在uitoolbar上面
- 9. UICollectionViewCell在点击UITextView时滚动,在键盘解除时不向后滚动
- 10. 当键盘出现时,滚动查看不会滚动
- 11. 的UITextView避免键盘滚动
- 12. 即使出现键盘,滚动查看也不会滚动
- 13. 使UITextView可滚动
- 14. 键盘隐藏UITextView当它出现
- 15. 使键盘自动出现
- 16. 布局在键盘出现时向上滚动
- 17. 如何在键盘出现时在列表视图中向上滚动
- 18. 如何在键盘已经启动时触摸UITextView来缩回键盘?
- 19. 页面滚动时,软键盘弹出
- 20. 显示键盘时可滚动吗?
- 21. 当键盘可见时滚动内容
- 22. iPad上的UIModalPresentationFormSheet。如何在出现键盘时调整UITextView高度
- 23. 如何在键盘出现在内部时移动视图ConstraintLayout
- 24. 获取UItextview键盘动画
- 25. 当键盘出现时,如何使CCTextFieldTTF向上移动:Cocos2d-x
- 26. 当键盘出现时调整UITextView的大小(Swift)
- 27. 当出现键盘时调整UITextView的大小
- 28. 键盘出现时底部对话框片段不能滚动
- 29. 当键盘出现时,Swift向上滚动查看
- 30. 当键盘出现导致崩溃时滚动到底部
更改滚动视图,它是不是键盘背后了的大小。 – dasdom