内容如何设置的TextView的滚动型的大小直接用户启动时滚动或当轻敲上的TextView(how

2019-10-30 19:29发布

UITextView中,在包括图像/( UIImageView )。

但是,当我想看到它是无法看到图像/滚动,

我中实现的逻辑,以与各自的动态地增加滚动内容大小的文字的大小,

- (void)scrollViewDidScroll:(UIScrollView *)scrollview 
{
      if (scrollview.contentOffset.y >= scrollview.contentSize.height - scrollview.frame.size.height) 
      {

            CGSize s = [messageView.text sizeWithFont:[UIFont systemFontOfSize:25] //define your textview font size
                                    constrainedToSize:CGSizeMake(self.view.bounds.size.width - 40, MAXFLOAT)  // - 40 For cell padding
                                        lineBreakMode:UILineBreakModeWordWrap];   

            // To increase the text view scroll content to display image also
            [scrollview setContentSize:CGSizeMake(200, s.height+150)];

      }       
}

但是,当在文本视图文本超过其(TextView的)边界仅在启动滚动。

无法看到完整的图像,如果文本是在边界(没有线可以在文本视图适合)

How to set scroll size when touch / starts scrolling on textview ,,

Answer 1:

使用此代码文本设置为消息查看(之后UITextView

    messageView.frame = CGRectMake(messageView.frame.origin.x, messageView.frame.origin.y, messageView.frame.size.width, messageView.contentSize.height + 150);
    float fscrview = messageView.frame.origin.y + messageView.frame.size.height + 150;
    scrollview.contentSize=CGSizeMake(320, fscrview);


文章来源: how set content size of textView's Scrollview immediately when user starts scrolling or when tap on textview