是否可以在没有用户滚动的情况下拥有UIScrollView,因此可以以编程方式滚动UIScrollView吗?
答案 0 :(得分:2)
是的,您可以使用这些方法以编程方式滚动:
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated
您也可以设置userInteractionEnabled=NO
以禁用用户触摸事件。
答案 1 :(得分: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];
}