Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.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
Iphone 如何设置textView的内容大小';当用户开始滚动或点击文本视图时,立即滚动视图_Iphone_Objective C_Uiscrollview_Uitextview - Fatal编程技术网

Iphone 如何设置textView的内容大小';当用户开始滚动或点击文本视图时,立即滚动视图

Iphone 如何设置textView的内容大小';当用户开始滚动或点击文本视图时,立即滚动视图,iphone,objective-c,uiscrollview,uitextview,Iphone,Objective C,Uiscrollview,Uitextview,我在include image/(UIImageView)中有UITextView) 但当我想看到图像时,它无法看到/滚动 我实现了逻辑,根据文本大小动态增加滚动内容大小 - (void)scrollViewDidScroll:(UIScrollView *)scrollview { if (scrollview.contentOffset.y >= scrollview.contentSize.height - scrollview.frame.size.height)

我在include image/(
UIImageView
)中有
UITextView

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

我实现了逻辑,根据文本大小动态增加滚动内容大小

- (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)边界时,它才会开始滚动

如果文本在边界内,我无法看到完整图像(文本视图中没有行可以容纳)


在文本视图上触摸/开始滚动时如何设置滚动大小

将文本设置为消息视图后使用此代码(
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);