我该如何创建一个水平滚动的UITextView?
当我通过编程设置文本时,它会自动添加换行符,因此我只能垂直滚动...
感谢你的回答。
编辑: 到目前为止,我尝试了以下内容:
但我收到了这样的信息:'威胁 1:信号 SIGABRT'
当我通过编程设置文本时,它会自动添加换行符,因此我只能垂直滚动...
titleView.text = @"this is a very long text. this is a very long text. this is a very long text. this is a very long text. this is a very long text.";
感谢你的回答。
编辑: 到目前为止,我尝试了以下内容:
UIScrollview *yourScrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(0 ,0 , self.view.frame.size.width, 50)];
CGFloat textLength = [titleView.text sizeWithFont:titleView.font constrainedToSize:CGSizeMake(9999, 50) lineBreakMode:NSLineBreakByWordWrapping].width;
yourScrollview.contentSize = CGSizeMake(textLength + 200, 500); //or some value you like, you may have to try this out a few times
titleView.frame = CGRectMake(titleView.frame.origin.x, titleView.frame.origin.y, textLength, titleView.frame.size.height);
[yourScrollview addSubview: titleView];
NSLog(@"%f", textLength);
但我收到了这样的信息:'威胁 1:信号 SIGABRT'