사과가 공개 API를 사용하여 지원하지 않기 때문에 나는 이것에 대한 오히려 더러운 해결책이 있습니다. 내 구현 작업은 훌륭하게 종료되며 향후 일부 API가 변경되면 충돌이 발생하지 않아야합니다 (더 이상 작동하지 않음). UITableView
을 서브 클래 싱하는 중이며 테이블에 서브 뷰로 추가 될 때 sectionIndex 뷰에 자체 콜백을 추가합니다.
@interface MyTableView : UITableView
@end
@implementation MyTableView
- (void)selectionStarted {
[self setSectionIndexColor:[UIColor greenColor]];
}
- (void)selectionStoped {
[self setSectionIndexColor:[UIColor redColor]];
}
- (void)addSubview:(UIView *)view {
[super addSubview:view];
if ([NSStringFromClass([view class]) isEqualToString:@"UITableViewIndex"] && [view isKindOfClass:[UIControl class]]) {
UIControl *cont = (UIControl *)view;
[cont addTarget:self action:@selector(selectionStarted) forControlEvents:UIControlEventTouchDown];
[cont addTarget:self action:@selector(selectionStoped) forControlEvents:UIControlEventTouchUpInside];
[cont addTarget:self action:@selector(selectionStoped) forControlEvents:UIControlEventTouchUpOutside];
[cont addTarget:self action:@selector(selectionStoped) forControlEvents:UIControlEventTouchCancel];
}
}
@end
셀 색상 변경 ... 또는 섹션 선택을 선택한 다음 섹션 색상 변경을 의미합니까? –
전체 색인 또는 선택한 항목의 색상을 변경 하시겠습니까? –
@Jonathan Cichon : 전체 색인 만. 선택되지 않은 상태에서는 어두운 색을, 선택된 상태에서는 밝은 색을 가져야합니다. – AlexVogel