0

所以我创建了一个 UITextView 并将它放在一个 UIScrollView 中。但是,我禁用了 UITextView 的滚动,所以我想知道在滚动 UIScrollView 时是否可以同时滚动 textview?

我不确定是否有人已经问过这样的问题,我试图通过该网站进行搜索,但找不到与我的问题相关的任何主题。如果有这样的现有帖子,如果有人将我链接到它,我将不胜感激。

4

1 回答 1

1

UIScrollView是滚动的UIView。因此,您只需将其UITextView作为子视图添加到滚动视图中,它就会随之滚动,基本上是这样的:

UIScrollView *scrollView = [UIScrollView alloc]initWithFrame:CGRectMake(0,0,320,460)];//adjust the frame to fit your needs
scrollView.contentSize = CGSizeMake(400, 600);//make sure the size in contentSize is bigger than the size of the scrollView frame: (400, 600) is bigger than (320, 460), otherwise the scroll effect won't be performed
UITextView *textView = [UITextView alloc]initWithFrame:CGRectMake(0,0,200,400)];//adjust the frame to fit your needs
[scrollView addSubview:textView];//need to add the text view as a subview 
[self.view addSubview:scrollView];
于 2013-04-08T00:35:59.190 回答