简体   繁体   English

未调用UITableview委托

[英]UITableview delegate is not being called

  1. I have drag the tableview into a view controller. 我已经将tableview拖到视图控制器中。
  2. i have created an outlet property to the table . 我已经为表创建了一个插座属性。

    @property (strong, nonatomic) IBOutlet UITableView *tableView; @属性(强,非原子)IBOutlet UITableView * tableView;

  3. i have added the delegate in the interface 我已经在界面中添加了委托

    UITableViewDelegate 的UITableViewDelegate

    4.registered the delegate with : 4.注册代表:
    tableView.delegate=self;

and added all functions of a tableview, that usually did worked before : 并添加了tableview的所有功能,这些功能通常在以下情况下就可以实现:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

And all the others. 还有其他所有。 the functions are not being called at start. 这些函数在开始时没有被调用。

What am i missing here ? 我在这里想念什么?

You are missing the tableView's dataSource. 您缺少tableView的dataSource。 These methods appear on the dataSource, not the delegate. 这些方法出现在数据源上,而不是在委托上。

Set tableView.dataSource=self; 设置tableView.dataSource=self; as well, and you should be good to go. 以及,您应该很好。

UITableView has two delegates delegate and dataSource as they handle different areas of focus. UITableView有两个委托, delegatedataSource因为它们处理不同的焦点区域。

You may be missing one of the following things. 您可能缺少以下内容之一。

1.Make sure you have set your datasource and delegate of your TableView as your current view controller by Xibs or by code. 1.确保已通过Xibs或代码将数据源和TableView的代理设置为当前视图控制器。

2.Do mention your protocal that you have to implement in header of your like below. 2.请在下面的标题中提及您必须实现的协议。

@interface ViewController()<UITableViewDataSource,UITableViewDelegate>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM