1

是否有可能在用户无法滚动的情况下拥有 UIScrollView,因此是否可以通过编程方式滚动 UIScrollView?

4

2 回答 2

2

是的,您可以使用这些方法以编程方式滚动:

- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated

您也可以设置userInteractionEnabled=NO禁用用户触摸事件。

于 2011-09-01T19:59:31.250 回答
0

试试这个:

-(void)scrollViewProgramatically
{
        UIScrollView *scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(x, y, 250, 150)];
        scrollview.showsVerticalScrollIndicator=YES;
        scrollview.scrollEnabled=YES;
        scrollview.userInteractionEnabled=YES;
        scrollview.backgroundColor = [UIColor whiteColor];
        scrollview.contentSize = CGSizeMake(1250,250);
        [scrollview addSubview:scrollview];
}
于 2013-11-19T12:17:51.397 回答