brunow / BaseKit

BaseKit is a set of IOS class to make your life easier.
https://twitter.com/brunowernimont
Apache License 2.0
265 stars 25 forks source link

How to use BKTableModel in UIViewController? #9

Closed steve21124 closed 12 years ago

steve21124 commented 12 years ago

Currently, BKTableModel use UITableViewController instead of UIViewController. I create table automatically using UITableView.

brunow commented 12 years ago

It's very simple here is a simple example:

UITableView *myTableView = [[UITableView alloc] initWithFrame:CGRectZero];
BKTableModel *model = [BKTableModel tableModelForTableView:myTableView];

Just provide your tableview instance when you instantiate your tablemodel

steve21124 commented 12 years ago

It give error "CellMappingExample[16650:207] -[BKTableModel superview]: unrecognized selector sent to instance 0x6a2caf0"

// self.tableView= [[UITableView alloc] initWithFrame:CGRectZero]; self.tableView= [[UITableView alloc] initWithFrame:self.view.bounds]; // self.tableView = [BKTableModel tableModelForTableView:self.tableView delegate:self]; [self.view addSubview:self.tableView];

----------- This below create UITableView fine @interface TableViewControllerExample : UIViewController<BKTableModelDataSource,UITableViewDataSource,UITableViewDelegate>{

}

brunow commented 12 years ago

You must not do that, BKTableModel don't hinerit from UITableView self.tableView = [BKTableModel tableModelForTableView:self.tableView delegate:self];

Instead do some like self.tableModel = [BKTableModel tableModelForTableView:self.tableView delegate:self]; were tableModel is a property of type BKTableModel

steve21124 commented 12 years ago

thanks