2012-06-02 59 views
0

在我的tableview中,我使用背景圖像作爲我的細胞(完全黑色的圖像),我也想在我的細胞中使用附件指示器。在細胞的屬性窗口,我設置AccessoryDisclosureIndicatorios - tableview附件指示器未顯示

在我的.m文件,我把這些代碼的實現代碼如下:

- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath{ 

    return UITableViewCellAccessoryDisclosureIndicator; 

} 

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


    UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 
     cell.backgroundColor = [UIColor clearColor]; 

    } 

    cell.textLabel.backgroundColor=[UIColor clearColor]; 
    cell.textLabel.text=[arrMagaza objectAtIndex:indexPath.row]; 
    cell.textLabel.textColor=[UIColor whiteColor]; 


    NSString *distance=[arrDistance objectAtIndex:indexPath.row]; 
    cell.detailTextLabel.backgroundColor=[UIColor clearColor]; 
    cell.detailTextLabel.textColor=[UIColor whiteColor]; 
    cell.detailTextLabel.text=[distance stringByAppendingFormat:@" km"]; 

    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; 

    return cell; 
} 


- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { 
    cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tablecell.png"]]; 
    tableView.backgroundColor=[UIColor blackColor]; 
    tableView.separatorColor= [UIColor clearColor]; 
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; 
} 

但是當我運行應用程序的輔助指標不是在視圖中顯示。 我做錯了什麼?是關於我用於細胞的背景圖像的問題嗎?

+0

請發佈添加圖片的代碼 –

+0

如何設置單元格的背景圖片?你的代碼是好的我認爲這個問題是你通過指標繪製圖像。刪除backgorund圖片只是爲了測試。並且你不應該在單元格的backgorund顏色上有清晰的顏色,這將以低速滾動速度結束 –

+0

感謝您的建議我刪除該代碼 – ercan

回答

0
- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath 

此方法現在不推薦使用,所以不需要實現此方法。嘗試刪除一切看起來不錯。

+0

是的,我刪除了代碼,現在它的工作原理,但我有一個問題:UITableViewCellAccessoryDisclosureIndicator,但在白色是否可以改變它的顏色以及如何? – ercan

+0

對於使用自定義圖像設置accessoryView與單元格和UIImageView並將自定義圖像(白色DisclosureIndicator)設置爲圖像視圖。 –