2010-03-03 30 views
0

是否有任何簡單的方法將「UITableViewCellAccessoryCheckmark」的顏色從標準藍色更改爲黑色? 或者我需要做一個uitableviewcell的子類並插入一個imageview我自己?黑色的UITableViewCellAccessoryCheckmark?

感謝:-) 塞巴斯蒂安

回答

1

據我知道有沒有這樣做的方式。

我最終爲我的accessoryView實現了一個完整的自定義視圖。它還使得用戶交互時更改它更容易,並且決定可點擊區域,而這往往是我想要的方法。如果你不需要不同的觀點,我想你只需要一個按鈕即可。

我做了一個customView,在裏面放置了一個透明的按鈕。這個觀點我添加到單元格:

CustomDisclosureArea *disArea = [[CustomDisclosureArea alloc] init]; 
[disArea setFrame:CGRectMake(280.0f, 0.0f, 40.0f, 71.0f)]; 
[disArea setTag:DISCLOSURE_ID]; 
[disArea.emptyButton addTarget:self action:@selector(cellButtonHandler:event:) forControlEvents:UIControlEventTouchUpInside]; //this the button inside the view. 
[cell.contentView addSubview:disArea]; 
[disArea switchToState:AreaStateBlank]; //I can set it to different states (blank, checkmark, empty etc. 
[disArea release]; 

現在,當被竊聽的accessoryView的是一個有點特殊的,因爲我們需要知道哪些細胞被竊聽所調用的方法。

- (void) cellButtonHandler:(id)sender event:(id)event { 

    NSSet *touches = [event allTouches]; 
    UITouch *touch = [touches anyObject]; 
    CGPoint currentTouchPosition = [touch locationInView:self.tableView]; 
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition]; 
} 

但你最終的NSIndexPath,這是一樣的,你會在didSelectRow或與accessoryButtonTapped方法獲得。

希望這會幫助,如果你決定做一個自定義的accessoryView的:)

+0

非常感謝。 像這些零件讓我想知道爲什麼蘋果不吃自己的食物,並在我設置風格時填充accessoryView。 ;-) – Sebastian 2010-03-04 10:58:35

0

我還沒有嘗試過,但它可能是可以簡單地詢問了小區的物業accessoryView並找到對號和替換另一個圖像(它幾乎肯定是一個圖像)。我認爲,單元格樣式只是一個默認樣式的表格單元格,其中包含複選標記的圖像單元格。

+0

如果你自己沒有明確設置它,那麼accessoryView就是零。如果設置爲 ,那麼accessoryType將被忽略。 – Sebastian 2010-03-04 11:01:32

+0

無賴。我希望它可能更簡單。 – TechZen 2010-03-04 13:25:01