UITableView用什么样的设计模式来填充,有什么好处? 它是委托模式吗?我所要求的理由是,它不仅仅是委托,而且也是数据源。看起来更像是与MVC一致。UITableView用于填充什么设计模式以及委托和数据源设置有哪些好处?
我刚刚经历了几个在线教程他们\我的代码工作,但它看起来像我缺少point.I结束所有这些方法在我的主控制器。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10;//any number based on datasource size.
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
// Set up the cell...
cell.text = [names objectAtIndex:indexPath.row];//names is an array.
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
它是一个视图基于应用程序。它应该是在一个sperate controller.Otherly看起来很混乱,并在做一些简单的顶级方式。我一点都不认为Objective C或苹果是错误的,但我只是一个初学者,并且错过了这个代表和数据源设置的全部意义。
这样总结可以有人请解释:
1,请告诉我该委托和数据源设置的好处?
2 - 这是什么设计模式的名称?
3 - 我应该有一个单独的控制器(在基于视图的应用程序中)?
感谢您的回复我只是想看看#pragma的外观如何,可以找到函数列表。我在哪里可以看到添加这个结果。 –
您有源代码编辑器区域上边缘的方法列表。点击它,你会看到方法列表,并在其中添加#pragma标记。 – Yuji
伟大甚至不知道这一点。感谢帮助。 –