Fails to call delegate/datasource methods in UITableView implementation

后端 未结 2 1816
温柔的废话
温柔的废话 2020-12-22 05:45

I have created .h and .m files for UITableView called mainTableViewgm.h and mainTableViewgm.m resp. and I am calling -initWithFr

2条回答
  •  有刺的猬
    2020-12-22 06:13

    I can't believe I've been doing XCode programming for two years, and still hit this issue.

    I had the same problem with XCode 6.1 - I was setting my UITableView's delegate & dataSource in the viewWillAppear function, but none of the delegate functions were kicking in.

    However, if I right-clicked on the UITableView on the Storyboard, the circles for delegate and dataSource were empty.

    The solution, then, is to hold down the CTRL key, and drag from each of these circles up to the name of your UIView which contains your UITableView:

    enter image description here

    After doing this, my UITableView happily populated itself.

    (So, we're upto v6.1 of XCode now are we ? Do you think Apple ever going to make this thing, you know, friendly...? I would quite like to add a Bookmark in my code... that'd be a nice feature.)

提交回复
热议问题