Typing while animation UITextView

↘锁芯ラ 提交于 2019-12-18 18:10:19

问题


I'm trying to have a variable-height UITextView which changes size to accomodate its contents, but when the frame changes in the size-change animation, one or two keystrokes aren't captured in the UITextView. The animation duration is 0.1s, and typically it only misses one letter when you're typing fairly fast. It is, however, very consistent in missing letters when the animation happens. The following animation block occurs within the textViewDidChange: delegate message:

[UIView animateWithDuration:0.1 animations:^{

    [textView setFrame:CGRectMake(...)];

}];

I've Googled and searched on SO, but so far nothing has come up. Has anyone else encountered this?


回答1:


By default UIView animations disable user interaction for animated view, so possibly (sorry cannot test it now) explicitly enabling user interaction will solve your problem:

[UIView animateWithDuration:0.1 
        delay:0.0
        options: UIViewAnimationOptionAllowUserInteraction
        animations:^{    
            [textView setFrame:CGRectMake(...)];
        }    
        completion:^(void){}];


来源:https://stackoverflow.com/questions/6852020/typing-while-animation-uitextview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!