tableview封裝使用

下載地址git

 

使用方法github

  

   1. #import "ZFTableView.h"
  2.在須要使用的地方添加ZFTableView 以下
   
  ZFTableView *tab = [[ZFTableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
  tab.cellInfos = self.infos;
  tab.separatorStyle = UITableViewCellSeparatorStyleNone;
  [self.view addSubview:tab];
   
  self.infos 是tableview的數據
   
  3.添加數據
   
  傳入數據必須爲包含ZFTableViewCellModel或子類型的數組
  傳入cellName表示cell爲代碼建立的cell
  傳入xibCellName表示cell爲xib建立的cell
  自定義cell須要繼承自ZFTableViewCell
   
  如需使用tableView其餘功能,請重寫delegate方法
   
  -(NSMutableArray *)infos{
   
  if (_infos == nil) {
  NSMutableArray *arr =[NSMutableArray arrayWithObjects:@"ZFCollectionViewLayoutCircleType",@"ZFCollectionViewLayoutStackType",@"ZFCollectionViewFlowLayoutRotatePageType",@"ZFCollectionViewFlowLayoutWaterfallType",@"ZFCollectionViewFlowLayoutLineType", nil];
  NSMutableArray *arr1 =[NSMutableArray arrayWithCapacity:1];
   
  for (int i =0; i < arr.count; i++) {
   
  ZFTableViewCellModel *model = [[ZFTableViewCellModel alloc] init];
  model.title = arr[i];
  model.PopToViewController = [NSString stringWithFormat:@"%@ViewController",arr[i]];
  // if (i != 1) {
  // model.cellName =@"demoTableViewCell";
  // }else{
   
  model.xibCellName =@"demo1TableViewCell";
   
  // }
   
  // model.imgName =[NSString stringWithFormat:@"%i",i];
  [arr1 addObject:model];
  }
  _infos = arr1;
  }
   
  return _infos;
  }
相關文章
相關標籤/搜索