开发者

Trying to adding a UITableView into a view hierchary with it's own view controller

I have a view hierarchy that has a UIViewController as Fi开发者_运维技巧les Owner in the XIB.

I need to add a UITableView into the hierarchy that has it's own controller (a UITableViewController subclass) because I am implementing a pull-to-refresh UI using http://github.com/leah/PullToRefresh

What I did:

  1. created the new UITableViewController subclass, BuddyTableViewController
  2. implemented the datasource & delegate methods
  3. added the UITableView into the hierarchy in Interface Builder
  4. dropped an NSObject into the XIB and set the class to BuddyTableViewController
  5. set the delegate & datasource of the tableview to BuddyTableViewController and hooked the UITableView to the tableView property of BuddyTableViewController

When the view displays it crashes immediately.

When running in debug with NSZombieEnable=YES reveals the message:

*** -[BuddyTableViewController numberOfSectionsInTableView:]: message sent to deallocated instance 0x69551d0

numberOfSectionsInTableView only contains return 1;

I don't understand why BuddyTableViewController is being deallocated.


You need to hook it up to an outlet in the owner, having it as delegate and data source is not enough because neither of those retains it. If the object is not retained by you it will be autoreleased.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜