2013-10-21 46 views
-1

我正在開發具有滑動窗口(如Facebook或Google +應用程序)的應用程序。我有一個主要的設置菜單,我已經爲應用程序的一部分構建。 我可以實現任何像JASidePanels這樣的github項目,我遇到的問題是我需要滑動設置菜單才能出現在應用程序的不同部分,並且滑動設置菜單必須相同。我可以通過爲每個ViewController建立自己的滑動設置菜單來解決這個問題,但我想問問其他人怎麼做到這一點?有沒有辦法只創建一個滑動設置菜單的實例,並在應用程序的不同部分使用它?滑動面板,多屏幕,iOS

回答

1

我使用ZUUIRevealController。

ZUUIRevealController

你可以得到這把你的菜單了任何視圖 - 控制

我使用這段代碼在我想要的菜單出現(我使用UINavigationController的每一個觀點,但你可以如果需要的話將其重寫爲不使用UINavigationController)。此代碼放置在viewDidLoad中

self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style: UIBarButtonItemStyleBordered target:nil action:nil]; 


if ([self.navigationController.parentViewController respondsToSelector:@selector(revealGesture:)] && [self.navigationController.parentViewController respondsToSelector:@selector(revealToggle:)]) 
    { 
      UIPanGestureRecognizer *navigationBarPanGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self.navigationController.parentViewController action:@selector(revealGesture:)]; 
      [self.navigationController.navigationBar addGestureRecognizer:navigationBarPanGestureRecognizer]; 

      self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:detail.menuTitle style:UIBarButtonItemStylePlain target:self.navigationController.parentViewController action:@selector(revealToggle:)]; 
    } 

編輯 - 現在有一個叫PKRevealController新版本已經取代ZUUIRevealController

PKRevealController

+0

看起來很有趣,但代碼似乎有點老了,沒有很多文檔。你在iOS 7中使用嗎? – Eddie

+0

是的,它是舊的我認爲它是圍繞iOS5開始使用它。我在一個項目中在iOS7中使用它 –

+0

存儲庫README上有一個鏈接,指向PKRevealController,它似乎是更新的版本。我已經更新了我的答案,並附有鏈接 –