如何将侧边栏菜单推到另一个视图iPhone中的控制器



我在我的应用程序中使用侧边栏菜单,就像在Facebook中一样,所以我在这个菜单中有不同的单元格,我想要的是当单击一个单元格时将我推到另一个视图控制器。我正在使用此代码。请给我任何想法

Viewcontroller.m

- (IBAction)onBurger:(id)sender 
{
 NSArray *images = @[
[UIImage imageNamed:@"gear"],
[UIImage imageNamed:@"globe"],
[UIImage imageNamed:@"profile"],
[UIImage imageNamed:@"star"],
[UIImage imageNamed:@"gear"],
[UIImage imageNamed:@"globe"],
[UIImage imageNamed:@"profile"],
[UIImage imageNamed:@"star"],
[UIImage imageNamed:@"gear"],
[UIImage imageNamed:@"globe"],
[UIImage imageNamed:@"profile"],
[UIImage imageNamed:@"star"],
];
NSArray *colors = @[
[UIColor colorWithRed:240/255.f green:159/255.f blue:254/255.f alpha:1],
[UIColor colorWithRed:255/255.f green:137/255.f blue:167/255.f alpha:1],
[UIColor colorWithRed:126/255.f green:242/255.f blue:195/255.f alpha:1],
[UIColor colorWithRed:119/255.f green:152/255.f blue:255/255.f alpha:1],
[UIColor colorWithRed:240/255.f green:159/255.f blue:254/255.f alpha:1],
[UIColor colorWithRed:255/255.f green:137/255.f blue:167/255.f alpha:1],
[UIColor colorWithRed:126/255.f green:242/255.f blue:195/255.f alpha:1],
[UIColor colorWithRed:119/255.f green:152/255.f blue:255/255.f alpha:1],
[UIColor colorWithRed:240/255.f green:159/255.f blue:254/255.f alpha:1],
[UIColor colorWithRed:255/255.f green:137/255.f blue:167/255.f alpha:1],
[UIColor colorWithRed:126/255.f green:242/255.f blue:195/255.f alpha:1],
[UIColor colorWithRed:119/255.f green:152/255.f blue:255/255.f alpha:1],
                        ];
    RNFrostedSidebar *callout = [[RNFrostedSidebar alloc] initWithImages:images selectedIndices:self.optionIndices borderColors:colors];
//    RNFrostedSidebar *callout = [[RNFrostedSidebar alloc] initWithImages:images];
callout.delegate = self;
//    callout.showFromRight = YES;
[callout show];
}
#pragma mark - RNFrostedSidebarDelegate
- (void)sidebar:(RNFrostedSidebar *)sidebar didTapItemAtIndex:(NSUInteger)index 
{
 NSLog(@"Tapped item at index %i",index);
if (index == 3) 
{
[sidebar dismiss];
}
else if(index==2)
{
[sidebar dismiss];
 }

else if(index==1)
{
[sidebar dismiss];
}
 else if(index==0)
{
[sidebar dismiss];
}
}
- (void)sidebar:(RNFrostedSidebar *)sidebar didEnable:(BOOL)itemEnabled itemAtIndex:(NSUInteger)index 
{
if (itemEnabled) 
{
[self.optionIndices addIndex:index];
 }
else 
{
[self.optionIndices removeIndex:index];
}
}

试试这个,我已经用过这个并且工作正常。JASidePanel是一个UIViewController容器,设计用于呈现带有可显示侧面板的中央面板 - 一个在左边,一个在右边。这个项目的主要灵感来自Path 2.0和Facebook的iOS应用程序中的菜单系统。

最新更新