资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

iOStableView的用法-创新互联

- (void)viewDidLoad

为行唐等地区用户提供了全套网页设计制作服务,及行唐网站建设行业解决方案。主营业务为成都网站制作、网站建设、外贸网站建设、行唐网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

{

  [super viewDidLoad];

   UITableView *myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, Screen_width, Screen_height)style:UITableViewStylePlain];

//  UITableViewStyleGrouped分组

  myTableView.dataSource = self;

  myTableView.delegate = self;

  [self cancelCell:myTableView];

  [self.view addSubview:myTableView];

     // Do any additional setup after loading the view,;typically from a nib.

}

#pragma mark-once 行数

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

   return 3;

}

#pragma mark-once 行内容

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

   static NSString *cellID = @"cellID";

   UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:cellID];

   if(cell==nil)

  {

    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];

  }

   //UITableViewCellStyle      是个枚举

   //UITableViewCellStyleDefault;  默认的

   //UITableViewCellStyleSubtitle;

   //UITableViewCellStyleValue1;

   //UITableViewCellStyleValue2;

  cell.textLabel.text = [NSString stringWithFormat:@"%ld",(long)indexPath.row];

   //给右边加个标识符的

  cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;

   //选中的颜色

  cell.selectionStyle = UITableViewCellSelectionStyleBlue;

   return cell;

}

#pragma mark-once 几组

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;

{

   return 2;

}

#pragma mark-once头标题

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

{

  return @"第一个标题";

}

#pragma mark-once未标题

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section

{

   return @"最后一个标题";

}

#pragma mark-once标识符accessoryButtonTappedForRow方法

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath

{

}

#pragma mark-once类似电话那种最右边的 a,b,c,d,e-z

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView

{

   NSArray *rightArry = @[@"A",@"B",@"c",@"d",@"e",@"f",@"g"];

   return rightArry;

}

#pragma mark-once行高

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

   return 50;

}

#pragma mark-once头标题的高度

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

{

   return 50;

}

#pragma mark-once未标题的高度

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section

{

   return 50;

}

#pragma mark-once行高

-(void)cancelCell:(UITableView *)tableView

{

   UIView *view = [UIView new];

  view.backgroundColor = [UIColor clearColor];

  [tableView setTableFooterView:view];

  view.frame = CGRectMake(0, 0, tableView.frame.size.width, 20);

}

#pragma mark-once 选中的方法

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

   NSLog(@"%ld",(NSInteger)indexPath.row);

}

#pragma mark-once编辑的方法

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath

{

   return YES;

}

#pragma mark-once是否允许移动

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath

{

   return YES;

}

#pragma mark-once 编辑的方法

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

{

}

#pragma mark-once 移动的方法

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath*)destinationIndexPath

{

}

#pragma mark-once 分割线

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

   if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {

    [tableView setSeparatorInset:UIEdgeInsetsZero];

  }

   if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {

    [tableView setLayoutMargins:UIEdgeInsetsZero];

  }

   if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {

    [cell setLayoutMargins:UIEdgeInsetsZero];

  }

}

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享名称:iOStableView的用法-创新互联
网站地址:http://cdkjz.cn/article/ppoph.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220