2011-04-08 55 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