我想点击一个按钮。滚动视图将滚动到某个y
位置,当我再次单击它时,它将返回到我当前在滚动视图中所处的位置。我无法理解。
int position1 = 0;
- (IBAction)scrollToPosition1:(id)sender {
int scrollYsaved;
position1++;
switch (position1) {
case 1:
scrollYsaved = scrollAll.contentOffset.y;
[scrollAll scrollRectToVisible:CGRectMake(10, 4190, scrollAll.frame.size.width, scrollAll.frame.size.height) animated:YES];
break;
case 2:
[scrollAll scrollRectToVisible:CGRectMake(10, scrollYsaved, scrollAll.frame.size.width, scrollAll.frame.size.height) animated:YES];
if (position1=2)
{
position1=0;
}
break;
}