-1

我的故事板中的 UITableView 对象理论上应该有它的委托集,但它没有。我将 UITableView 对象从故事板拖到标题中,并将其添加为 IBOutlet 属性并合成它。但是,我检查了一下,只调用了数据源方法。所以我实现主要委托协议的方式似乎有问题。正如您在下面的图片中看到的,我似乎在做所有事情都是标准的?但是代表还没有被设置!想法?

图 1

图 2

图 3

图 4

4

3 回答 3

2

I think the reason your solution is not working is because you are using a TableView inside of a UiViewController instead of a UiTableViewController. I had this same issue a while back. Here is what I did. Create an IBOutlet to the header file and synthesize it in the implementation file (I believe you have already completed this step). Go back to the storyboard. control + click on your table view and drag the connector to the view controller (the yellow circle with the white box). Select datasource. Repeat this step again and instead of selecting datasource select delegate. In the menu on the right-hand side you should be able to see your outlets if it is set up correctly. This should fix your delegate problems.

See the screenshot from my example below:

enter image description here

于 2013-10-07T03:25:55.160 回答
0

You have put a log in both numberOfRowsInSection: which is being called but not the one in cellForRowAtIndexPath: which shows that no cells are being created for your table. You simply are returning 0 as number of rows for the table. Check for that.

And the delegate method didSelectRowAtIndexPath: will be called when you select a row, but for that, you have to have a row first in your table.

于 2013-10-07T03:18:31.307 回答
0

尝试更改您的 numberOfRows 方法(以便更好地调试)。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    int rows = [allParties count];
    NSLog(@"number of rows: %d", rows);
    return rows;
}

如果您返回 0,它将不起作用。

同样在将来,请粘贴您的代码而不是截屏。

于 2013-10-07T03:00:40.203 回答