第二种方法如下:
UITableview *sTableView=[[UITableView alloc ]initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)];
sTableView.delegate=self;
sTableView.dataSource=self;
sTableView.tableFooterView=[[UIview alloc]initWithFrame:CGRectZero];
sTableView.separatorInset=UIEdgeInsetZero;
sTableView.layoutMargins=UIEdgeInsetZero;
[self.view addSubview:sTableView];
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *ID=@”cell”;
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
If(cell==nil){
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
cell.layoutMargins=UIEdgeInsetZero;
}
return cell;
}
第二种方法如下:
-(void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
if ([_moreTableView respondsToSelector:@selector(setSeparatorInset:)]) {
[_moreTableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
}
if ([_moreTableView respondsToSelector:@selector(setLayoutMargins:)]) {
[_moreTableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
}
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}