2011-11-08 147 views
1

我在我的应用程序中制作幻灯片。我希望它几乎像苹果的照片应用程序。几乎完成了一些小问题。我想在屏幕上点击时隐藏导航栏,然后再次点击时显示。但我不知道如何做到这一点。点击时隐藏导航栏

回答

2
// catch the screen tap and call a method to hide the navigation bar 
UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleNavBar:)]; 
[self.view addGestureRecognizer:gesture]; 
[gesture release]; 

- (void)toggleNavBar:(UITapGestureRecognizer *)gesture { 
    BOOL barsHidden = self.navigationController.navigationBar.hidden; 
    [self.navigationController setNavigationBarHidden:!barsHidden animated:YES]; 
} 
+0

你知道如何让navbar变得透明吗?另外一个小问题是当导航栏变淡时图像滚动一下。你知道如何解决这个问题吗?提前致谢。 – Dawid

+0

透明导航栏:http://stackoverflow.com/questions/7282691/ – Jano

1

你想如何隐藏导航栏?点击导航栏(这将是非常棘手的,如果不是彻头彻尾的不可能)或通过其他按钮或通过其他方法?

一般来说,你肯定可以隐藏导航栏。

[UINavigationController setNavigationBarHidden: animated:](我已经联系了苹果文档)

+0

我想在屏幕上点击时隐藏导航栏。就像在iPhone的照片应用程序。 – Dawid

+0

然后,Jano的答案应该做你正在寻找的东西。 :-) –

0
  1. 添加手势使用

UITapGestureRecognizer * theSingleTapGesture = [[UITapGestureRecognizer页头] initWithTarget到屏幕:自

action:@selector(handleSingleTapForImage :)]; [inImageView addGestureRecognizer:theSingleTapGesture]; [theSingleTapGesture发布];

  1. 手势的方法显示或隐藏导航栏

    -(void)handleSingleTapForImage:(UITapGestureRecognizer *)sender { 
    [self.navigationController setNavigationBarHidden:![self.navigationController isNavigationBarHidden] animated:YES]; 
    

    }

0

使导航半透明

self.navigationController.navigationBar.barStyle=UIBarStyleBlackTranslucent;