如何用屏幕的一部分切换视图

时间:2011-07-28 03:08:08

标签: iphone uimodaltransitionstyle

我的顶部有一个导航栏,底部有一个标签栏。然后我在导航栏上放置一个信息灯按钮。我的任务是按信息按钮将中间区域切换到另一个视图,并使导航栏和标签栏保持静止。

-(IBAction) infoButtonPressed:(id)sender
{
BMIInfo *infoView = [[BMIInfo alloc] initWithNibName:nil bundle:[NSBundle mainBundle]];

infoView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.navigationController pushViewController:infoView animated:YES];
[infoView release];

}

使用上面的代码,我只是将视图转换为翻译动作。我希望有一个轻松的举动。我该怎么办?

- (IBAction)infoButtonPressed:(id)sender;
{
BMIInfo *infoView = [[BMIInfo alloc] initWithNibName:nil bundle:nil];

infoView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:infoView animated:YES];

[infoView release];
}

然后我用翻转的方式切换屏幕,但它会切换整个屏幕。我希望标签栏保持不动。我也不希望标签栏切换。

2 个答案:

答案 0 :(得分:0)

目前尚不清楚你想要完成什么。

如果你想要一个模态视图,那么你应该使用像

这样的东西
[self presentModalViewController:navController animated:YES];

这样,除非您将其关闭,否则您之前的屏幕将以相同的方式保留。如果您打算在模态视图中使用导航和标签栏,则将该视图声明为TabBarController,并且可以在模态上为其提供navigationBar。

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:infoView];

navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:navController animated:YES];

答案 1 :(得分:0)

像这样的东西“

-(IBAction) infoButtonPressed:(id)sender
{
BMIInfo *infoView = [[BMIInfo alloc] initWithNibName:nil bundle:[NSBundle mainBundle]];


[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^(void) {
    [self.navigationController pushViewController:infoView animated:NO];
     [infoView release];
} completion:^(BOOL finished) {

}];




}