简体   繁体   中英

UITableview delegate is not being called

  1. I have drag the tableview into a view controller.
  2. i have created an outlet property to the table .

    @property (strong, nonatomic) IBOutlet UITableView *tableView;

  3. i have added the delegate in the interface

    UITableViewDelegate

    4.registered the delegate with :
    tableView.delegate=self;

and added all functions of a tableview, that usually did worked before :

- (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. These methods appear on the dataSource, not the delegate.

Set 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.

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.

2.Do mention your protocal that you have to implement in header of your like below.

@interface ViewController()<UITableViewDataSource,UITableViewDelegate>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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