2011-04-08 53 views
0

有没有办法允许用户选择一个tableViewCell,并让它看起来就像iPhone上的设置一样?在设置应用程序中,当您选择一行时,当您触摸时它会变成蓝色,然后当您触摸时,复选标记将从该行移动到新行,而蓝色消失。在设置中选择一个UITableViewCell

在我的应用程序中,我已经实现了相同的基本功能,除了我不知道如何淡化蓝色之外。我试着用淡入淡出的动画重新加载tableSection,但是它比设置更快地移除蓝色。另外,它会导致其他表格单元短暂闪烁。

我也试过只是将复选标记设置为新单元格,但将其留在旧单元格中,并且不删除突出显示。

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
    [defaults setObject:[[self.fetchedResults objectAtIndexPath:indexPath] languageCode] forKey:@"inputLanguage"]; 

    //[tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade]; 
    [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark; 
} 

回答

1

要取消的UITableViewCell做到这一点:

[tableView deselectRowAtIndexPath:indexPath animated:YES]; 
+0

谢谢!我知道这就是你如何取消选择一行;我只是没有意识到,这将提供我需要的动画外观。 – GendoIkari 2011-04-11 13:22:33