2014-02-16 19 views
0

我已經將UIImage添加到了我的表格視圖單元格中。但是,UIImage正在將分隔符推向右側,爲UIImage騰出空間。我想找到一種方法來讓分隔符包含UIImage,而不是推遲。這是我的表格視圖單元格的圖片。TableViewCell中的UIImage推送單元格分隔符

enter image description here

這裏是我的cellForRowAtIndexPath方法與形象代碼:

-(UITableViewCell *)tableView:(UITableView *)tableView 
    cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = 
    [tableView dequeueReusableCellWithIdentifier:CellIdentifier 
           forIndexPath:indexPath]; 

    Exercise *tempPlaceholder = [exercisesInTable objectAtIndex:indexPath.row]; 



    NSString *exerciseDisplayName = tempPlaceholder.exerciseName; 

    exerciseDisplayName = [exerciseDisplayName capitalizedString]; 

    exerciseDisplayName = 
    [exerciseDisplayName stringByReplacingOccurrencesOfString:@"_" 
               withString:@" "]; 

    cell.textLabel.text = exerciseDisplayName; 

    cell.imageView.image = [UIImage imageNamed:@"quads.png"]; 


    return cell; 
} 

如果有人可以幫助我解決這個我會很感激。謝謝。

+1

看看這個http://stackoverflow.com/questions/18365049/is-there-a-way-to-make-uitableview-cells-in-ios-7-not-have-a-line-break-in-the -s – Infinity

+0

謝謝,完美的工作。 – zic10

回答

1

對於其他人誰運行到這個問題,使用:

[self.tableView setSeparatorInset:UIEdgeInsetsZero]; 

將填補的UIImage和表細胞分離機之間的差距。

0

嘗試改變ImageView的框架

cell.imageView.frame = CGRectMake(0, 0, 10.0, 10.0); 

的大小或改變細胞

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    return 40.0; 
} 
0

的高度,遇到將於的iOS 7,其中隔板具有插圖纔會發生的行爲默認情況下隨圖像視圖大小而變化。

要刪除此行爲,只需將分隔符插入設置爲零。然而,separatorInset屬性可在UITableView的iOS 7.0

所以你只需要刪除插圖中的iOS 7

您可以檢查表視圖是否響應setSeparatorInset:

if ([self.tableview respondsToSelector:@selector(setSeparatorInset:)]) 
{ 
    [self.tableview setSeparatorInset:UIEdgeInsetsZero]; 
} 
相關問題