uiscrollview scrollRectToVisible:方法不起作用

时间:2012-11-05 18:33:20

标签: iphone ios xcode uiscrollview

当用户触摸屏幕时,我想向下滚动屏幕。我在我的vc中实现了touchesBegan:withEvent:方法,这就是我想出来的。

 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
       UIScrollView *scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width, self.view.frame.size.height)];
       scrollView.contentSize=CGSizeMake(self.view.frame.size.width, self.view.frame.size.height);
       [self.view addSubview:scrollView];
       [scrollView scrollRectToVisible:CGRectMake(0,100,self.view.frame.size.width,self.view.frame.size.height) animated:YES];

}

1 个答案:

答案 0 :(得分:0)

哦,我需要确保当我滚动到可见

时,我保持大小相同