2014-12-05 55 views
0

我有兩個viewControllers iPad就像facebook sidepanel一樣。有LeftViewController,當我點擊中心viewController上的按鈕時,它會切換。它在CenterViewController的頂部滑動。但它只涵蓋centerViewController的50%。嵌套UINavigationController的最佳方法

我應該可以將新視圖添加到左側viewController並且可以推送。

什麼是實現這一目標的最佳方法。

+0

我不明白,你問滑動邊欄(滑出或進入)? – 2014-12-05 05:33:36

+0

是的。我有滑動側欄,我應該能夠在視圖之間推送和彈出。 – 2014-12-05 05:38:43

+0

您是否在尋找帶側邊欄菜單的抽屜式控制器?像這個鏈接https://www.cocoacontrols.com/controls/mmdrawercontroller--2 – Esha 2014-12-05 05:40:59

回答

1

請檢查該鏈接

Sliding Drawers

[SideMenus]

這包含不同的抽屜,並迅速數太多。可能是這個鏈接會對你有所幫助。

+1

是@ kampai,但如果任何用戶想知道一些更好的庫,那麼作爲對用戶有幫助的東西的答案鏈接應該在那裏。我們可以在這裏設置鏈接到git或任何倉庫,所以我們可以給鏈接作爲答案。 :) – Esha 2014-12-05 06:22:14

0

你可以在view.see下面添加滑入側欄。

在.h文件中指定的屬性

UIView*menuDrawer; 

@property(readonly,nonatomic)UISwipeGestureRecognizer*recognizer_open,*recognizer_close; 
@property(readonly,nonatomic) int menuDrawerX,menuDrawerWidth; 

//自定義幻燈片菜單

添加該代碼在viewDidLoad中

int statusBarHeight=[UIApplication sharedApplication].statusBarFrame.size.height-20; 
    menuDrawerWidth=self.view.frame.size.width*0.65;//you can adjust width 
    menuDrawerX=self.view.frame.origin.x-menuDrawerWidth; 
    menuDrawer=[[UIView alloc]initWithFrame:CGRectMake(menuDrawerX, self.view.frame.origin.y+statusBarHeight, menuDrawerWidth,self.view.frame.size.height-statusBarHeight)]; 
    menuDrawer.backgroundColor=[UIColor 
           whiteColor]; 
    recognizer_close=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipes:)]; 
    recognizer_open=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipes:)]; 
    recognizer_close.direction=UISwipeGestureRecognizerDirectionLeft; 
    recognizer_open.direction=UISwipeGestureRecognizerDirectionRight; 


    [self.view addGestureRecognizer:recognizer_close]; 
    [self.view addGestureRecognizer:recognizer_open]; 
    [self.view addSubview:menuDrawer]; 

添加此方法

-(void)handleSwipes:(UISwipeGestureRecognizer*)sender 
{ 
    [self drawerAnimation]; 

} 

通話THI S分析,如果您分配一個按鈕,也可以設置一個按鈕,選擇

-(void)drawerAnimation 
{ 

[UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDuration:-5]; 

    CGFloat new_x = 0; 
    if (menuDrawer.frame.origin.x < self.view.frame.origin.x) { 
     new_x=menuDrawer.frame.origin.x + menuDrawerWidth; 
     } 
    else 
    { 
     new_x=menuDrawer.frame.origin.x - menuDrawerWidth; 
    } 
    menuDrawer.frame=CGRectMake(new_x, menuDrawer.frame.origin.y, menuDrawer.frame.size.width, menuDrawer.frame.size.height); 
    [UIView commitAnimations]; 


} 

它會正常工作,你可以在這些滑入側欄菜單中添加的UITableView或其他控件。

您可以通過statusBarHeight和menuDrawerWidth調整高度和寬度。