【问题标题】:how to switch view with a part of screen如何使用屏幕的一部分切换视图
【发布时间】:2011-07-28 03:08:08
【问题描述】:

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

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

通过这个,我以翻转方式切换屏幕,但它切换了整个屏幕。我希望标签栏保持静止。我也不想切换标签栏。

【问题讨论】:

    标签: iphone uimodaltransitionstyle


    【解决方案1】:

    不清楚你想要完成什么。

    如果你想要一个模态视图,那么你应该使用类似的东西

    [self presentModalViewController:navController animated:YES];
    

    这样,除非您将其关闭,否则您之前的屏幕将以相同的方式保留。如果您打算在模态视图中包含导航和选项卡栏,则将该视图声明为 TabBarController,并且您可以模态地为其提供一个导航栏。

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:infoView];
    
    navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:navController animated:YES];
    

    【讨论】:

    • 我想要导航栏上的信息按钮来翻转切换屏幕的一部分并保持底部标签栏静止
    • 我阅读了更新。模态视图控制器是不可能的。你得到一个新的屏幕。您可以复制那里的标签。请阅读文档。
    【解决方案2】:

    类似的东西”

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

    【讨论】:

    • 下面的代码只是切换视图但没有动画。
    猜你喜欢
    • 2017-12-02
    • 1970-01-01
    • 2010-12-28
    • 2022-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-08
    相关资源
    最近更新 更多