1
當用戶觸摸屏幕時,我想向下滾動屏幕。我在我的vc中實現了touchesBegan:withEvent:方法,這就是我想出的。uiscrollview scrollRectToVisible:方法不起作用
-(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];
}
這如果用戶觸摸由視圖控制器管理的視圖只會工作,即self.view。我猜self.view有一些子視圖,所以他們正在獲取觸摸事件。你想要做什麼? – hukir