2011-05-11 67 views
0

我有兩個表視圖,其中包含以下聲明。UITableView中的自定義accessoryView問題

cAboutUs = [[UITableView alloc] initWithFrame:CGRectMake(85, 272, 227, 30)]; 

ctableView = [[UITableView alloc] initWithFrame:CGRectMake(85, 302, 227, 100)];  

當我嘗試使用下面的代碼添加自定義附件視圖時,兩者都出現在單元格中的不同位置。 (在cAboutUs更向左(X)相比,ctableView細胞附件時)

UIImage *image = [UIImage imageNamed:@"bullet.png"]; 

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 
CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height); 
button.frame = frame; 

[button setBackgroundImage:image forState:UIControlStateNormal]; 
cell.accessoryView = button; 

我試圖同一通過使用

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator 

它正確地示出了具有良好對準。

請幫我解決這個錯誤。

+0

對於這兩種表格視圖使用相同的圖像,它如何產生問題。 – Hanuman 2011-05-11 09:19:03

+0

你是否同時顯示兩個表格視圖? – Jhaliya 2011-05-11 09:27:10

回答

0

它通過將cAboutUs表單元的高度增加到40來解決。奇怪但沒有理由解決它。

0

檢查兩個表格視圖中單元格的高度。

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
// Make sure height for the cells is the same 
}