我想知道是否有可能为UITableViewController自动打开现在部分,当有超过例如5行单元格在表中?具体来说,我想将物品1到物品5放在Section 1中,当用户添加更多物品时,新物品将自动放置在Section 2中。如何做到这一点?
谢谢
使用numberOfRowsInSection
:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 5;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
int sections = self.YOUR_DATASOURCE_ARRAY.count / 5;
return sections;
}
参见UITableViewDataSourceProtocol
参考:http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDataSource_Protocol/Reference/Reference.html