在我的viewcontroller中输入了scrollview中的所有对象。 scrollView中的一个按钮可以创建一个动画。
scrollView离开页面-80.0 orgine.y 到目前为止一切都那么好..现在我想要当你点击按钮滚动视图然后回到-80.0到+80.0自动返回到原来的位置所以...你能告诉我你最好的方法吗?此?
这是按下时按下按钮的动作......
- (IBAction)AcceptFriendRequest:(id)sender {
PFObject *SelectedUser = [self.UtentiInAttesa objectAtIndex:[sender tag]];
[SelectedUser setObject:@"Confermato" forKey:@"STATO"];
[SelectedUser saveInBackground];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.2];
[UIView setAnimationBeginsFromCurrentState:YES];
FFScrollView.frame = CGRectMake(FFScrollView.frame.origin.x, (FFScrollView.frame.origin.y - 80.0), FFScrollView.frame.size.width, FFScrollView.frame.size.height);
[UIView setAnimationRepeatAutoreverses:YES];
[UIView commitAnimations];
}
答案 0 :(得分:1)
在您的按钮事件处理程序
中- (IBAction)myBtnClicked:(id)sender {
// Create new CGRect indicate place where you would scroll to.
// Assume it is called `originalRect`
// Use the following method, it should work
[FFScrollView.scroll scrollRectToVisible:originalRect animated:YES];
}