只是想知道为什么我们不能以下面的方式将数据源设置为UITableview,而不是返回一种方法中的数据计数并以不同的方法返回单元格中的数据。UTableView数据源设置
为什么我们不做下面的事情?
UITableView *tableView = [UITableView alloc] init];
tableView.datasource = [NSArray arrayWithObjects:@"row1", @"row2", nil];
tableView.cellIdentifier = @"Identifier";
tableView.cell = [UITableViewCell alloc] init];
//delegate methods implemented as properties,
tableView.rowHeight = 50.0;
tableView.headerHeight = 100.0
tableView.headerView = [UIView alloc] init];
[self.view addSubView:tableView];
我们可以做到这一点吧,可能不是100%正确的,我们可以想添加一些更多的属性,使中的TableView它的工作原理现在以同样的方式。
乳清苹果公司以它现在的工作方式设计了TableView。如果有人能够用现有设计解释这种设计的优点和缺点,那么有用。
我有时为自己的类做了类似的事情,而不是实现数据源和委托方法。我想知道为什么。 – John