1.
self.myTableView.separatorStyle =UITableViewCellSeparatorStyleNone;//隐藏cell自带的线 2. cell.selectionStyle =UITableViewCellSelectionStyleNone;//去掉点击效果3.
cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;//自带指向尖头4.
self.myTableView.scrollEnabled = YES;//进制滚动5.
//下划线长度 //UIEdgeInsetsZero 下划线为屏幕的宽 //UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>) 细微调整 [self.myTableView setSeparatorInset:UIEdgeInsetsZero]; //下划线颜色 [self.myTableView setSeparatorColor:[UIColor xxxx ]]; [self.myTableView setLayoutMargins:UIEdgeInsetsZero]; - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell; [cell setSeparatorInset:UIEdgeInsetsZero]; [cell setLayoutMargins:UIEdgeInsetsZero]; return cell; } 6.UITableView协议方法 -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath //设置分组标识 -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; //返回数据源中组的个数 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;//返回数据源每组中数据个数 -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;//返回每一个cell的高度 -(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section//自定制tableView的HeaderView(头视图)的样式 -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;//返回每组头所对应的头的高度 -(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section//自定制tableView的FooterView(尾视图)的样式 -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;//返回每组头所对应的尾的高度 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;//执行点击每一个cell的方法 firstTableview.sectionIndexColor = [UIColorclearColor];//设置默认时索引值颜色 firstTableview.sectionIndexTrackingBackgroundColor = [UIColorclearColor];//设置选中时,索引背景颜色 //返回每个索引的内容 -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section; //返回索引数组 -(NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView;-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{ return UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert; } -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{//设置删除数据源里的某一条信息 if (editingStyle ==UITableViewCellEditingStyleDelete) { if (tableView ==self.mytableview) { [self.datasourceremoveObjectAtIndex:indexPath.row]; [self.mytableviewbeginUpdates]; [self.mytableviewdeleteRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationAutomatic]; [self.mytableviewendUpdates]; } } } - (IBAction)delete:(id)sender { if (self.mytableview.isEditing) { [self.mytableview beginUpdates]; NSArray * selectRows = [self.mytableview indexPathsForSelectedRows]; NSMutableIndexSet * indexpaths = [[NSMutableIndexSet alloc] init]; for(NSIndexPath * path in selectRows){ [indexpaths addIndex:path.row]; } [self.datasource removeObjectsAtIndexes:indexpaths]; [self.mytableview deleteRowsAtIndexPaths:selectRows withRowAnimation:UITableViewRowAnimationAutomatic]; [self.mytableview endUpdates]; [self.mytableview setEditing:NO animated:YES]; }else{ [self.mytableview setEditing:YES animated:YES]; } }
