2011-03-09 60 views

回答

0

FlipView方法加載的UIView編程

在.h文件中使用此代碼

@interface MainViewController : UIViewController { 
    IBOutlet UIView *secondaryView; 
} 
- (IBAction)toggleView:(id)sender; //Action for toggle view 
- (IBAction)returnView:(id)sender; 


@end 

在.M

- (IBAction)toggleView:(id)sender { 
     [UIView beginAnimations:nil context:nil]; 
     [UIView setAnimationDuration:1.0]; 
     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight 
           forView:[self view] 
           cache:YES]; 
     [[self view] addSubview:secondaryView]; 
     [UIView commitAnimations]; 
    } 

    //Flips to front when "Done" is pressed 
    - (IBAction)returnView:(id)sender { 
     [UIView beginAnimations:nil context:nil]; 
     [UIView setAnimationDuration:1.0]; 
     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft 
           forView:[self view] 
           cache:YES]; 
     [secondaryView removeFromSuperview]; 
     [UIView commitAnimations]; 
    } 

您可以檢查此教程http://www.vimeo.com/5653713如果任何混淆。