2009-05-20 8 views
1

J'ai un UIView qui a un bouton, Sur le robinet du bouton, je montre un nouveau UIView qui contient un UINavigationBar et un UITableView. Y at-il un moyen d'animer un effet de flip sur le robinet et de charger la vue et vice versa?Flip vues dans l'iPhone?

Répondre

1

Bien sûr, est un code ici qui peut aider

- (void)flipAction:(id)sender 
{ 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:0.75]; 
    // checks to see if the view is attached 
    [UIView setAnimationTransition:([logTextView superview] ? 
            UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight) 
          forView:[self view] cache:YES]; 
    [UIView setAnimationTransition:([logTextView superview] ? 
            UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight) 
          forView:[[self navigationController] view] cache:YES]; 
    if ([logTextView superview]) 
    { 
     [logTextView removeFromSuperview]; 
     self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"FTP Log", nil) style:UIBarButtonItemStyleBordered target:self action:@selector(viewFtpLog)]; 
    } 
    else 
    { 
     [[self view] addSubview:logTextView]; 
     [[[self navigationItem] rightBarButtonItem] release]; 
     self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Done", nil) style:UIBarButtonItemStyleDone target:self action:@selector(flipAction:)]; 
    } 

    [UIView commitAnimations]; 
} 

Pour vous, vous pouvez obtenir le UIView pour votre point de vue de la table. Le bouton est ce qui déclenche le flip

+0

Aussi, je garde une référence à logTextView en tant que @property dans mon UIViewController –