2013-10-25 220 views
0

在我的viewcontroller中輸入了滾動視圖中的所有對象。 scrollView中的一個按鈕創建一個動畫。UiScrollView滾動UiView

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

這可能是很好的開始你來處理這個問題:HTTPS: //developer.apple.com/library/ios/documentation/windowsviews/conceptual/viewpg_iphoneos/ViewPG_iPhoneOS.pdf – babygau

回答

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]; 
}