0

その中 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)];

      }       
}

ただし、テキストビュー内のテキストが(テキストビュー)境界を超えた場合にのみスクロールを開始します。

テキストが境界内にある場合、完全な画像を見ることができませんでした (テキスト ビューに収まる行がありません)。

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

4

1 に答える 1

0

テキストを messageView( 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);
于 2012-12-05T11:09:11.930 に答える