5 행이있는 간단한 tableView를 만들었습니다. 셀에 UITableViewCellAccessoryCheckmark를 사용했습니다.action from UITableViewCellAccessoryCheckmark
버튼을 누르고 '확인 된'셀과 그렇지 않은 셀을 기준으로 작업을 수행하려고합니다. 사용자가 none, all, 1 등을 선택할 수 있습니다.
UITableViewCellAccessoryCheckmark를 사용하는 셀과 UITableViewCellAccessoryNone을 사용하는 셀을 확인하려면 어떻게합니까?
감사
샘
편집! 내가 할 수있는 방법을 발견
... didSelectRowAtIndexPath에서
나는 한 다음 ...
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
NSUserDefaults *loginDefaults = [NSUserDefaults standardUserDefaults];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:indexPath];
if (oldCell.accessoryType == UITableViewCellAccessoryCheckmark)
{
oldCell.accessoryType = UITableViewCellAccessoryNone;
} else {
UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
if (newCell.accessoryType == UITableViewCellAccessoryNone)
{
newCell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}
if ([oldCell.textLabel.text isEqualToString:@"All"]) {
if (oldCell.accessoryType == UITableViewCellAccessoryCheckmark) {
[loginDefaults setObject:@"YES" forKey:@"DownloadAll"];
} else if (oldCell.accessoryType == UITableViewCellAccessoryNone) {
[loginDefaults setObject:@"NO" forKey:@"DownloadAll"];
}
} else if
집 주위
조금,하지만 난 단지 내 테이블에 5 일을 가지고 보기, 그것은 내가하고 싶은 것을 위해 잘 작동합니다.
이제 행동에, 나는 NSUserDefaults의 값을 확인하고 요소가 모델에 속하는 일입니다 확인하는 대해 따라