0

我有一个控制器视图,其中包括(图像和文本)。

两个组件在 中UIScrollView,图像是UIImageView,文本是UITextView(启用滚动)。当我试图滚动整个屏幕时,文本不会随之滚动,因为它有自己的滚动。

我需要的是用整个屏幕滚动器滚动文本。(将文本的卷轴与整个卷轴合并)。

我应该将文本类型更改为标签而不是 textview 还是我应该做什么?

谢谢你,

4

2 回答 2

0

使用这种方法:

- (void)textViewDidBeginEditing:(UITextView *)textView
{
    if(textView==your_textview)
    {
        [yourscroolview setContentOffset:CGPointMake(0,textView.center.y-180) animated:YES];
    }


}
- (void)textViewDidEndEditing:(UITextView *)textView
{
    [yourscroolview resignFirstResponder];
    [yourscroolview setContentOffset:CGPointMake(0,0) animated:YES];

}
于 2013-04-29T09:49:29.190 回答
0

如果在加载时分配viewWillAppear:文本,只需在您的方法中添加此代码..UITextView

yourTextView.frame = CGRectMake(yourTextView.frame.origin.x, yourTextView.frame.origin.y, yourTextView.frame.size.width, yourTextView.contentSize.height);
yourTextView.text=@"Your Text";
float fscrview = yourTextView.frame.origin.y + yourTextView.frame.size.height + 20;
yourScrollView.contentSize=CGSizeMake(320, fscrview);

对于前。

yourTextView.delegate = self;
yourTextView.userInteractionEnabled = NO;
yourTextView.backgroundColor = [UIColor clearColor];
yourTextView.font = [UIFont fontWithName:@"Helvetica" size:12.0];
yourTextView.textColor = [UIColor whiteColor];
yourTextView.text = @"Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.<br />\r\nLorem ipsum dolor sit amet, consetetur sadipscing elitr.<br />\r\nLorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr. Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.<br />\r\nLorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr. Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.Lorem ipsum dolor sit amet, consetetur sadipscing elitr.";
yourTextView.frame = CGRectMake(yourTextView.frame.origin.x, yourTextView.frame.origin.y, yourTextView.frame.size.width, yourTextView.contentSize.height);
float fscrview = yourTextView.frame.origin.y + yourTextView.frame.size.height + 20;
yourScrollView.contentSize=CGSizeMake(320, fscrview);
于 2013-04-29T09:51:54.850 回答