0
出于某种原因,我在执行删除操作后在我的tableviewcell上得到缩进。UITableViewCell在删除后缩进
-(void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
HMFAlbum *album = [self albumsForListState][indexPath.row];
if ([album.tracks containsObject:[[GVMusicPlayerController sharedInstance] nowPlayingItem]]) {
[[GVMusicPlayerController sharedInstance] stop];
}
if ([[HMFDatabaseManager sharedManager] deleteDeviceAlbum:album]) {
NSLog(@"Deleted Album");
//remove album from originalArray
NSMutableArray *modifiedDeviceAlbums = [NSMutableArray arrayWithArray:self.originalDeviceAlbumsArray];
[modifiedDeviceAlbums removeObject:album];
self.originalDeviceAlbumsArray = modifiedDeviceAlbums;
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
} else {
NSLog(@"failed to delete Album");
tableView.editing = false;
}
}
这是前后截图。
我试图这样做是为了消除没有成功:(
-(void)viewDidLayoutSubviews
{
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsZero];
}
if([self.tableView respondsToSelector:@selector(setCellLayoutMarginsFollowReadableWidth:)])
{
self.tableView.cellLayoutMarginsFollowReadableWidth = NO;
}
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
// Remove seperator inset
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
// Prevent the cell from inheriting the Table View's margin settings
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
[cell setPreservesSuperviewLayoutMargins:NO];
}
// Explictly set your cell's layout margins
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
[cell setSeparatorInset:UIEdgeInsetsZero];
}
}
编辑1问题:据我了解,这是正在缩进单元格的内容视图