所以我创建了一个UITextView并将它放在UIScrollView中。但是,我禁用滚动UITextView,所以我想知道是否有可能在滚动浏览我的UIScrollView的同时滚动textview?用UIScrollview滚动UITextview
我不确定是否有人已经问过这样的问题,我试图通过网站搜索,找不到与我的问题有关的任何主题。如果有这样一个现有的职位,我会很感激,如果有人指责我。
所以我创建了一个UITextView并将它放在UIScrollView中。但是,我禁用滚动UITextView,所以我想知道是否有可能在滚动浏览我的UIScrollView的同时滚动textview?用UIScrollview滚动UITextview
我不确定是否有人已经问过这样的问题,我试图通过网站搜索,找不到与我的问题有关的任何主题。如果有这样一个现有的职位,我会很感激,如果有人指责我。
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];
还需要设置滚动视图的contentSize。如果contentSize小于滚动视图的大小,则不会发生滚动。 – user523234 2013-04-08 01:54:11
感谢您的回答,但是您能否详述一下contentSize?对不起,我是新编辑的客户端C – 2013-04-08 03:02:05
,@ user523234 thanx。 – Malloc 2013-04-08 17:20:26
所以你想了'UIScrollView'的滚动绑定到'UITextView'? – 2013-04-08 00:06:16
是的差不多那 – 2013-04-08 03:03:00