이것은 아마도 내가 이해하지 못하는 간단한 문제 일 것이라고 생각하지만 시간을 많이 썼기 때문에 내 작업을 고수하고 있습니다.UITableViewController를 밀고 데이터를 필터링/다시로드
"topics"의 4 행을 표시하는 UITableViewController가 있습니다. 하나를 만지면, 그것은 내 UITableViewController 클래스의 인스턴스를 만들고, 데이터 소스 배열을 "부차 뷰"의 배열로 설정하고 컨트롤러를 nav 스택에 푸시합니다. 10 개의 행으로 "모든"주제 페이지로 이동하면 결과를 필터링 할 수있는 분할 된 컨트롤이 있습니다. 배열을 성공적으로 필터링 할 수 있지만 self.topicsDataSource에 할당하고 [self.tableView reloadData]를 호출하면 아무 일도 일어나지 않습니다. 대리자는 numberOfSections 및 numberOfRowsInSection 메서드를 사용하지만 cellForRowAtIndexPath 메서드는 그렇지 않습니다. 내비게이션 뒤로 버튼을 누르면 이전 테이블이 맨 위 테이블에서 필 터링 된 결과가됩니다.
여기 내가 생각하는 바가 있습니다. 1. 이전 테이블의 데이터 소스를 실제로 변경하고 있으며 해당 테이블에서 self.tableView.reloadData가 호출되고 있습니다. 2. 다시로드중인 tableview가 표시되지 않으므로 cellForRowAtIndexPath가 호출되지 않습니다.
여기 내가 테이블 뷰를 푸시하는 것을 인스턴스화합니다.
- (void)segControlChanged:(UISegmentedControl *)sender
{
self.allTopics = [NSMutableArray arrayWithArray:[DataManager getTopicsAtEndOfTree]];
if (sender.selectedSegmentIndex == 1) {
NSPredicate *pred = [NSPredicate predicateWithFormat:@"type == 2"];
NSMutableArray *mArr = [[NSMutableArray alloc] initWithArray:[self.allTopics filteredArrayUsingPredicate:pred]];
self.topicsDataSource = mArr;
}
else if (sender.selectedSegmentIndex == 2) {
NSPredicate *pred = [NSPredicate predicateWithFormat:@"type == 1"];
NSMutableArray *mArr = [[NSMutableArray alloc] initWithArray:[self.allTopics filteredArrayUsingPredicate:pred]];
self.topicsDataSource = mArr;
}
else {
NSMutableArray *mArr = [[NSMutableArray alloc] initWithArray:[DataManager getTopicsAtEndOfTree]];
self.topicsDataSource = mArr;
}
[self.tableView reloadData];
}
어떤 도움을 주시면 감사하겠습니다 : 나는 데이터를 필터링하고있는 tableView를 다시로드하고 곳이 클래스는 여기
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSNumber *idtopic = [[self.topicsDataSource objectAtIndex:indexPath.row] idtopic];
NSArray *subtopics = [DataManager getSubtopicsForTopic:idtopic];
if ([subtopics count] > 0) {
TopicsViewController *topicsVC = [[TopicsViewController alloc ] init];
topicsVC.tableView.rowHeight = 106;
topicsVC.parentTopicId = idtopic;
topicsVC.topicsDataSource = [NSMutableArray arrayWithArray:subtopics];
topicsVC.diseaseStateId = self.diseaseStateId;
topicsVC.title = [[self.topicsDataSource objectAtIndex:indexPath.row] topic];
[self.navigationController pushViewController:topicsVC animated:YES];
}
else if (![[self.topicsDataSource objectAtIndex:indexPath.row] topic]) {
//all topics was selected
TopicsViewController *topicsVC = [[TopicsViewController alloc] initWithNibName:nil bundle:nil];
topicsVC.tableView.rowHeight = 106;
NSMutableArray *mArray = [[NSMutableArray alloc] initWithArray:[DataManager getTopicsAtEndOfTree]];
topicsVC.allTopics = mArray;
topicsVC.topicsDataSource = topicsVC.allTopics;
topicsVC.diseaseStateId = self.diseaseStateId;
topicsVC.parentTopicId = [NSNumber numberWithInt:100];
UISegmentedControl *segControl = [[UISegmentedControl alloc] initWithItems:[[NSArray alloc] initWithObjects:@"All", @"Speaker Direct", @"Live Meeting", nil]];
[segControl addTarget:self action:@selector(segControlChanged:) forControlEvents:UIControlEventValueChanged];
[segControl setSegmentedControlStyle:UISegmentedControlStyleBar];
[segControl setSelectedSegmentIndex:0];
topicsVC.navigationItem.titleView = segControl;
topicsVC.tableView.dataSource = topicsVC;
[self.navigationController pushViewController:topicsVC animated:YES];
}....
TopicsViewController
라고하고있다. 감사!