翻转iPhone中的视图?

时间:2009-05-20 05:43:37

标签: iphone xcode

我有一个UIView,其中有一个按钮,点击按钮,我会显示一个新的UIView,其中包含UINavigationBarUITableView。有没有办法在按钮的点按上设置翻转效果并加载视图,反之亦然?

1 个答案:

答案 0 :(得分:1)

当然,这里有一些可能有用的代码

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

对于您,您可能希望获得表格视图的UIView。按钮是触发翻转的按钮