1

Is it possible to have a UIScrollView without the user being able to scroll and therefore is it possible to scroll a UIScrollView programmatically?

2 Answers2

2

Yes, you can use these methods to scroll programmatically:

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

You may also set userInteractionEnabled=NO to disable user touching events.

XMLSDK
  • 259
  • 1
  • 10
0

Try This:

-(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];
}
Rajesh Loganathan
  • 11,129
  • 4
  • 78
  • 90