많은 iPhone 응용 프로그램에서 체크 상자 목록으로 사용되는 UITableViewController가 나타납니다. (내 말은, 설정의 자동 잠금 기능을 참조하십시오.)체크 상자 목록으로 UITableViewController를 사용할 때 기본 항목 선택
이 기능을 직접 구현하는 동안 기본적으로 프로그래밍 방식으로 항목을 선택하려면 여러 가지 기능을 사용해야했습니다. , 목록이 나타내는 현재 값).
- (void)viewDidAppear:(BOOL)animated {
NSInteger row = 0;
// loop through my list of items to determine the row matching the current setting
for (NSString *item in statusItems) {
if ([item isEqualToString:currentStatus]) {
break;
}
++row;
}
// fetch the array of visible cells, get cell matching my row and set the
// accessory type
NSArray *arr = [self.tableView visibleCells];
NSIndexPath *ip = [self.tableView indexPathForCell:[arr objectAtIndex:row]];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:ip];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
self.lastIndexPath = ip;
[super viewDidAppear:animated];
}
이 특정 셀과 indexPath 경우에 대한 참조를 가져이 가장 좋은/만/가장 쉬운 방법입니다 : 가장 좋은 나는 내보기 컨트롤러 클래스의 viewDidAppear 방법을 재정 의하여이다 마련 할 수있었습니다 기본적으로 행을 표시하고 싶습니다.
나는 그 코드에 멍청하다고 생각했다. 오늘은 천천히 두뇌 : P – Dana