Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在UIView动画中最初调整UITextView帧大小时跳转_Ios_Objective C_Uitextview_Uiviewanimation - Fatal编程技术网

Ios 在UIView动画中最初调整UITextView帧大小时跳转

Ios 在UIView动画中最初调整UITextView帧大小时跳转,ios,objective-c,uitextview,uiviewanimation,Ios,Objective C,Uitextview,Uiviewanimation,我有以下代码来扩展文本区域&每当用户点击字段并开始编辑时,它就是superview: - (void)textViewDidBeginEditing:(UITextView *)textView { textView.text = @""; CGRect titleViewFrame = self.titleLabel.frame; titleViewFrame.size.height = kExpandedSubviewFrameHeight; CGRect

我有以下代码来扩展文本区域&每当用户点击字段并开始编辑时,它就是superview:

- (void)textViewDidBeginEditing:(UITextView *)textView
{
    textView.text = @"";

    CGRect titleViewFrame = self.titleLabel.frame;
    titleViewFrame.size.height = kExpandedSubviewFrameHeight;

    CGRect titleTextViewFrame = self.titleTextView.frame;
    titleTextViewFrame.size.height = kExpandedSubviewFrameHeight;

    [UIView animateWithDuration:0.4f
        animations:^{
                         self.titleLabel.frame = titleViewFrame;
                         self.titleTextView.frame = titleTextViewFrame;
        }];
}
一切正常,除了用户第一次点击此字段外,文本视图的y原点跳高一点:


非常感谢您的帮助。

有点晚了,但我在调整uitextview的大小时遇到了同样的问题,我认为这与文本视图的滚动有关。这是我的代码,当设置高度动画时,反弹为0。我使用NSLayoutConstraint来调整我的身高

- (void)textViewDidChange:(UITextView *)textView
{
    CGSize size = [messageView sizeThatFits:CGSizeMake(messageView.frame.size.width, FLT_MAX)];
    [UIView animateWithDuration:0.4f
                     animations:^{
                         messageHeightConstraint.constant = size.height;
                         [self.view layoutIfNeeded];
                     }
                     completion:^(BOOL finished) {
                         [messageView scrollRangeToVisible:NSMakeRange([messageView.text length], 0)];
                     }
    ];

}

你也在调整键盘吗?如果是这样,那么您应该从willShow通知中获取时间、持续时间和大小。不,字段足够高,不需要调整键盘。谢谢。您可能只想设置标题视图帧的动画,而不想设置文本视图帧的动画(因为没有边框)。在动画的完成块中设置textView帧。