마지막으로 나를 죽이는 문제가 있습니다. tableView:accessoryTypeForRowWithIndexPath
메서드를 사용하는 이전 프로젝트를 가지고 놀고 있는데, 그 중 어떤 것을 사용하지 않고 응용 프로그램을 다시 작성하려고합니다.iphone (objective-c) 액세서리 수정 오류
tableView:accessoryTypeForRowWithIndexPath
메서드를 삭제했지만 솔루션이 아직 작동하지 않습니다.
내 DetailViewController보기에서 '편집'버튼을 누르면 '편집'액세서리 유형이 표시되지 않습니다.
아래 실제 코드는 project file입니다. 작동하는 솔루션이 절실히 필요합니다.
제 질문은 변경해야 할 코드, 액세서리를 바꾸는 것, 그리고 다른 효과는 없습니다. (필자는 RootViewController 작동 알고 있지만, 어떻게 내가이 DetailViewController 테이블이 같은 행동을 할 수 있습니까?)
감사합니다, @norskben
프로젝트 파일 다운로드 :Get it here.
setEditing을
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
[self.navigationItem setHidesBackButton:editing animated:animated];
[tableView reloadData];
}
cellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tblView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.editingAccessoryType = UITableViewCellAccessoryCheckmark;
}
switch(indexPath.section) {
case 0:
cell.textLabel.text = coffeeObj.coffeeName;
break;
case 1:
cell.textLabel.text = [NSString stringWithFormat:@"%@", coffeeObj.price];
break;
}
return cell;
}
프로젝트 파일 다운로드 : 당신의 setEditing:animated:
방법에서은 Get it here.
이상하게도 옳은 방향으로 귀하의 작은 찌르다가 다 해결했습니다. 샘플을 비교하고 있었고 DetailViewController가 UITableViewController가 아닌 UIViewController라는 것을 알았습니다. (인터페이스 빌더 내가 처음보기에서 tableview과보기를 연결)). 코드와 인터페이스 빌더를 변경 한 다음 액세서리가 작동했습니다!. 그 다음으로 할 일은 행 삭제가없는 빨간색 아이콘을 제거하기위한 코드를 추가하는 것이었고 퍼즐의 마지막 비트는 self.tableView.allowsSelectionDuringEditing = YES; // viewDidLoad에서 de-added. 정말 고맙습니다. – oberbaum