2011-11-08 64 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;