iOS UITableView重新加载

问题描述:

我遇到了一块UITableView的代码,点击单元并重新加载,但究竟是什么数据源?我对此不太清楚。iOS UITableView重新加载

[xTable reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:button.tag inSection:0],nil] withRowAnimation:UITableViewRowAnimationFade]; 
+0

写下该函数的整个代码 –

它运行以下“tableview cellForRowAtIndexPath”方法并加载指定单元格的更新信息。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

希望它有帮助。

数据源是在定义一组消息,所述的UITableView发送给该对象(数据源) 这些消息返回填充在的tableview 内部的某些信息是像数据的UITableView的协议:

numberOfRowsInSection:你将返回的行数此表将有 cellForRowAtIndex:你会在这里返回的UITableViewCell对象为给定的指标 numberOfSectionsInTableView:您将返回该表将有

节数这是如何工作 在你的类,你会打电话给tableView.dataSource = self; [UITableView reloadData]得到执行,数据源的信息被发送到数据源对象(在这个例子中,将可以在对象上.dataSource = self;

表视图右侧将使用这些连续通话设置建表视图本身

对于进一步深入的阅读,请逆向工程&来

Simple tutorial on how to implement the datasource in iphone

Data Source design pattern

+0

[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:button.tag inSection:0],nil]表示加载一个来自itslef的对象的NSArray?这听起来有点像循环推理。 –