2011-06-01 100 views
0

我想要实现在默认情况下一个单元格中选择了一个特定的值的tableview,我们可以选择其它小区和刻度线出现就可以了。在一次选择一个特定的单元格为特定的值。TableView单元格选择问题?

我想实现这个通过我们解析特定国家API符合国家的选择。

在此先感谢。

+2

有什么问题吗? – 2011-06-01 20:39:24

回答

1

除非这是一个iPad应用程序用的tableview的左侧窗格中,留下一个UITableView与所选的UITableViewCell是针对苹果的人机界面指南。苹果更喜欢你只使用刻度标记(UITableViewCell附件类型设置为UITableViewCellAccessoryCheckmark),以表明特定行被选中。

下面是一些代码,让你开始:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    NSArray *visibleCells = [tableView visibleCells]; 
    // Remove checkmark from all visible cells 
    for (UITableViewCell *aCell in visibleCells) { 
    aCell.accessoryType = UITableViewCellAccessoryNone; 
    } 
    // Now add the tick mark to the selected cell 
    UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath]; 
    selectedCell.accessoryType = UITableViewCellAccessoryCheckmark; 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
} 

不要忘记设置相应的accessoryType在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath实现了。