Невозможно вызвать UITableView делегат метод "DidSelectRowAtIndexPath" - PullRequest
1 голос
/ 02 января 2012

Привет! Я использую searchDisplayController для фильтрации результатов поиска. Мой фрагмент кода выглядит следующим образом:

- (void)viewDidLoad
{
    [super viewDidLoad];

    //Set up search bar
    UISearchBar *tempBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0,0,320,40)];
    self.sBar = tempBar;
    [tempBar release];
    self.sBar.delegate = self;
    self.sBar.tintColor = [UIColor colorWithHexString:@"#b6c0c7"];
    self.sBar.placeholder = @"Search Questions and Topics";

    [self.view addSubview:sBar];

    self.filteredListContent = [NSMutableArray arrayWithCapacity:[self.listContent count]];

    self.searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:sBar contentsController:self];
    [self setSearchDisplayController:searchDisplayController];
    [searchDisplayController setDelegate:self];
    [searchDisplayController setSearchResultsDataSource:self];

// restore search settings if they were saved in didReceiveMemoryWarning.
    if (self.savedSearchTerm)
    {
        [self.searchDisplayController setActive:self.searchWasActive];
        [self.searchDisplayController.searchBar setText:savedSearchTerm];

        self.savedSearchTerm = nil;
    }

    [self.resultTableView reloadData];
    self.resultTableView.scrollEnabled = YES;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"zzz");
}

Нужно ли устанавливать что-либо в моем представлении, которое загружается, чтобы вызвать подходящий метод делегата?

Обратите внимание, что я уже объявил UISearchDisplayDelegate, UISearchBarDelegate, UITableViewDataSource, UITableViewDelegate в моих файлах .h. Также мой tableView cellForRowAtIndexPath метод работает.

1 Ответ

3 голосов
/ 02 января 2012

Вы действительно установили

self.tableView.delegate = self

или подключил его в Интерфейсном Разработчике

...