Ios 表视图委托方法未全部调用

Ios 表视图委托方法未全部调用,ios,objective-c,tableview,Ios,Objective C,Tableview,在我的代码中,我使用的是一个tableview,其中一些方法被调用,而另一些则没有 在initwithframe中: _table.delegate = self; _table.dataSource = self; 这叫做 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *identifier

在我的代码中,我使用的是一个tableview,其中一些方法被调用,而另一些则没有

在initwithframe中:

_table.delegate = self;
_table.dataSource = self;
这叫做

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"TRAutocompleteCell";

    id cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil)
        cell = [_cellFactory createReusableCellWithIdentifier:identifier];

    NSLog(@"got here 3");

    NSAssert([cell isKindOfClass:[UITableViewCell class]], @"Cell must inherit from UITableViewCell");
    NSAssert([cell conformsToProtocol:@protocol(TRAutocompletionCell)], @"Cell must conform TRAutocompletionCell");
    UITableViewCell <TRAutocompletionCell> *completionCell = (UITableViewCell <TRAutocompletionCell> *) cell;

    id suggestion = self.suggestions[(NSUInteger) indexPath.row];
    NSAssert([suggestion conformsToProtocol:@protocol(TRSuggestionItem)], @"Suggestion item must conform TRSuggestionItem");
    id <TRSuggestionItem> suggestionItem = (id <TRSuggestionItem>) suggestion;

    [completionCell updateWith:suggestionItem];

    return cell;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*标识符=@“TRAutocompleteCell”;
id单元格=[tableView dequeueReusableCellWithIdentifier:identifier];
如果(单元格==nil)
cell=[\u cellFactory createReusableCellWithIdentifier:identifier];
NSLog(@“到达这里3”);
NSAssert([cell isKindOfClass:[UITableViewCell类]],@“cell必须从UITableViewCell继承”);
NSAssert([cell conformsToProtocol:@协议(TRAutocompletionCell)],@“cell必须符合TRAutocompletionCell”);
UITableViewCell*completionCell=(UITableViewCell*)单元格;
id suggestion=self.suggestions[(NSUInteger)indexath.row];
NSAssert([建议符合协议:@协议(建议项目)],@“建议项目必须符合建议项目”);
id suggestionItem=(id)建议;
[completionCell updateWith:suggestionItem];
返回单元;
}
但这不是在同一个文件中调用的

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"got here 5");
    id suggestion = self.suggestions[(NSUInteger) indexPath.row];
    NSLog(@"got here 4");
    NSAssert([suggestion conformsToProtocol:@protocol(TRSuggestionItem)], @"Suggestion item must conform TRSuggestionItem");

    self.selectedSuggestion = (id <TRSuggestionItem>) suggestion;

    _queryTextField.text = self.selectedSuggestion.completionText;
    [_queryTextField resignFirstResponder];

    if (self.didAutocompleteWith)
        self.didAutocompleteWith(self.selectedSuggestion);

}
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(nsindepath*)indepath{
NSLog(@“到达这里5”);
id suggestion=self.suggestions[(NSUInteger)indexath.row];
NSLog(@“到达这里4”);
NSAssert([建议符合协议:@协议(建议项目)],@“建议项目必须符合建议项目”);
self.selectedSuggestion=(id)suggestion;
_queryTextField.text=self.selectedSuggestion.completionText;
[_queryTextField辞职FirstResponder];
if(self.didAutocompleteWith)
self.didAutocompleteWith(self.selectedSuggestion);
}

问题不在于实现,而在于我的手势识别

我在视图中添加了一个列表器,以捕获正在调用的文本框外的点击事件。我不知道为什么这两个是冲突,但当我删除它,它是工作

“表格视图”用于在我的文本框中自动完成。

您是否执行了以下操作:

yourTableView.delegate = self;
yourTableView.dataSource = self;
在创建tableView时


如果是.xib文件,是否连接了委托和数据源?

是否确定已将表与UITableView挂钩?从您编写的内容来看,问题似乎出在UITableViewDelegate上。您确定要实现该协议吗?在.h文件中添加此协议UITableViewDelegate@pe60t0:在新编译器中根本不需要它。是的,我有它们:@interface TRAutocompleteView:UIView。还是不叫。我真的不明白这怎么可能