欢迎光临
我们一直在努力

菜单目录

建站超值云服务器,限时71元/月

菜单目录

项目介绍:

Usage

// initialize menu data

NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"district" ofType:@"json"]];
NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
NSDictionary *realData = jsonDic[@"data"];
RicDistrictMenu *rootDataModel = [RicDistrictMenu new];
[rootDataModel setValuesForKeysWithDictionary:realData];

RicMenuItem *rootItem = [[RicMenuItem alloc] initWithDelegate:self oriData:rootDataModel defaultSelections:nil];

_menuView = [[RicMenuView alloc] initWithFrame:RicBaseFilterViewContentBounds];
[_menuView setDelegate:self rootItem:rootItem];

[self.view addSubview:_menuView];

// get the result

NSArray *result = _menuView.filteredLeafMenuItems;

// delegates
- (void)filterMenuDidClickedItem:(RicMenuItem *)item
{  
// for clicking the item in the menu
}

- (BOOL)supportMutiSelectionForItem:(RicMenuItem *)item{
// for selection enable    
if(item.allSubMenusAreLeaves){
    return YES;
}else{
    return NO;
}
}

- (void )configTableViewAtDepth:(NSInteger)depth tableView:(UITableView *)tableView
{
UIColor *bgColor = [UIColor whiteColor];
if(depth == 0){
    bgColor = [UIColor colorWithRed:243.0f/255.0f green:243.0f/255.0f blue:243.0f/255.0f alpha:1.0f];
}else if(depth == 1){
    bgColor = [UIColor colorWithRed:113.0f/255.0f green:133.0f/255.0f blue:153.0f/255.0f alpha:1.0f];
}
tableView.backgroundColor = bgColor;
}

// 返回一个偏移量给tableView
- (CGFloat )widthOfTableViewOfMenu:(RicMenuItem *)menu
{
CGFloat width = [UIScreen mainScreen].bounds.size.width/3.0f;    
return width;
}

// 这个代理方法需要指定 filterController的 heightForRowAtIndexPath 和 tableViewCellClass 两个属性
// config the MenuController
- (void)configControllerOfMenu:(RicMenuItem *)menu controller:(RicMenuController *)controller
{
RicMenuController *subMenuController = controller;    
subMenuController.heightForRowAtIndexPath = ^CGFloat(NSInteger depth,NSIndexPath *indexPath,RicMenuItem *subMenu){
  if(depth == 0){
      return 50.0f;
  }else if(depth == 1){
      return 60.0f;
  }else{
      return 40.0f;
  }
};
if(menu.depth == 0){
  subMenuController.tableViewCellClass = [RicMenuDepth0Cell class];
}else if(menu.depth == 1){
  if([menu.tag isEqualToString:@"location_district"]){
      subMenuController.tableViewCellClass = [RicMenuDepth1Cell class];
  }else{
      subMenuController.tableViewCellClass = [RicMenuDepth2Cell class];
  }
}else if (menu.depth == 2){
  subMenuController.tableViewCellClass = [RicMenuDepth2Cell class];
}
}

// add actions for your cells
// cell 动作
- (void)configureActionsForCell:(UITableViewCell *)cell{
NSLog(@"configure cell here");
}

Integration:

To integrate the control use Cocoapods add the line below into your Podfile:

pod:’RicMenuView’,’~>0.0.1′

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 菜单目录
分享到: 更多 (0)