I've added a UITableView component to a ViewController in Interface Builder to make it easier to customise as the UITableViewController won't let me set a background image.
I've then implemented some basic functions just to test if it works, but cannot get it to display any cells - does anyone have any suggestions on how to get it working?
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 1) {
return 2;
}
else {
return 1;
}
}
I've created a UITableView IBOutlet called tripSettings and have wired it up as a referencing outlet
Make sure that the tableView as your view controller as dataSource
and delegate
.
you have to make your class inherit from UIViewController , and then set the delegate and datasource to the file's owner using the interface builder
For tableView, several entities in an app must interact: the view controller, the table view itself, and the table view’s data source and delegate.
精彩评论