蓝色选择器 - iPhone

时间:2012-03-21 15:32:52

标签: iphone xcode selector didselectrowatindexpath

当我移回视图时,如何让蓝色选择器关闭?此刻,当我选择它时,我会被推到另一个视图。但是,当我回到原始视图时,它仍然被选中。

enter image description here

当我回到原始视图时,如何将其关闭?

感谢。

3 个答案:

答案 0 :(得分:3)

tableView:didSelectRowAtIndexPath:方法中,您应该包含以下内容:

[tableView deselectRowAtIndexPath:indexPath animated:YES];

答案 1 :(得分:0)

我"永远"视图消失时取消选择行:

-(void)viewDidDisappear:(BOOL)animated {
    int i = 0;
    while (YES) {
        NSIndexPath *path = [NSIndexPath indexPathForRow:i++ inSection:0];
        if ([yourTable cellForRowAtIndexPath:path] == nil) { break; }
        [yourTable deselectRowAtIndexPath:path animated:NO];
    }
}

Haven未检查代码

答案 2 :(得分:0)

你也可以尝试这个

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"myCellId";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

}
// Set up the cell...
cell.textLabel.text = @"foo";
return cell;
}