0

您好,我有一个带有视图控制器的应用程序,我在其中显示一些文本 - 它还有一个工具栏和一个导航栏。

我希望当我按下一个按钮来隐藏导航栏和工具栏以及状态栏并使带有文本的视图全屏显示并且如果用户点击视图导航栏和工具栏来显示。

那么我该怎么做呢?我尝试使用视图的 frame 属性,但没有成功。

编辑这里是我现在的代码。我的问题只有 1 - 状态栏未填充 - 它只是一个黑色的东西。

- (IBAction)goFullScreen:(id)sender {
    self.isFullScreenOn = !self.isFullScreenOn;
    if (self.isFullScreenOn) {
        self.navigationController.navigationBarHidden = NO;
        self.toolbar.hidden = NO;
        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
        self.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    }else{
        [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
        self.navigationController.navigationBarHidden = YES;
        self.toolbar.hidden = YES;
        self.view.frame = CGRectMake(0, -60, self.view.frame.size.width, self.view.frame.size.height + 60);
    }
}
4

5 回答 5

2

试试这个

[[UIApplication sharedApplication] setStatusBarHidden: YES withAnimation: UIStatusBarAnimationFade]; 

[self.navigationController setNavigationBarHidden:YES animated:YES];
于 2012-08-14T09:46:10.580 回答
1

隐藏导航栏: -

            self.navigationController.navigationBarHidden = YES ;

隐藏状态栏: -

            [[UIApplication sharedApplication] setStatusBarHidden:YES];

设置hidden工具栏属性

于 2012-08-14T09:42:32.157 回答
1

最初让栏不隐藏

self.currentView.toolBar.hidden=NO;

现在要让它在屏幕上单击显示和消失,在视图控制器中添加一个轻触识别器

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
    tapGesture.numberOfTapsRequired=1;
    [self.currentView addGestureRecognizer:tapGesture];
    [tapGesture release];

现在将 handleTapGesture 函数定义为

-(void) handleTapGesture:(UITapGestureRecognizer *)sender {

     if(self.currentView.toolBar.alpha==1.0 ){

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.8];
    self.currentView.toolBar.alpha = 0.0;
    //similarly add other properties to be hidden like label,button etc
    [UIView commitAnimations]; 
}
else{

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.8];
    self.currentView.toolBar.alpha = 1.0;
    [UIView commitAnimations]; 
}

}

于 2012-08-14T11:12:20.360 回答
0

hidden导航栏和工具栏的属性设置为YES

于 2012-08-14T09:39:56.427 回答
0

您可以使用 presentModalViewController 显示一个新的 Viewcontroller。您可以简单地再次关闭它,而不必进行任何调整。

于 2012-08-14T09:42:21.103 回答