只是想知道爲什麼我們不能以下面的方式將數據源設置爲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