2016-02-20 95 views
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; 
    } 

} 

這是前後截圖。

enter image description hereenter image description here

我試圖這樣做是爲了消除沒有成功:(

-(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問題:據我瞭解,這是正在縮進單元格的內容視圖

回答

0

我通過將其添加到單元格的子類中進行了修復

- (void)layoutSubviews { 
    self.contentView.frame = self.bounds; 
}