Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 更新uitableview单元格对象_Iphone_Uitableview_Uiwebview - Fatal编程技术网

Iphone 更新uitableview单元格对象

Iphone 更新uitableview单元格对象,iphone,uitableview,uiwebview,Iphone,Uitableview,Uiwebview,我有一个tableview,它的第一行包含一个uiwebview。当用户单击按钮时,我想用新对象更改此表的webview对象。我正在使用下面给出的代码,但它不能正常工作。旧的对象在那里,新的对象在上面,尽管我重新创建了webview。如何将旧的从单元格中删除 谢谢 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSStr

我有一个tableview,它的第一行包含一个uiwebview。当用户单击按钮时,我想用新对象更改此表的webview对象。我正在使用下面给出的代码,但它不能正常工作。旧的对象在那里,新的对象在上面,尽管我重新创建了webview。如何将旧的从单元格中删除

谢谢

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    NSLog(@"NİL.......");
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
} else {
    NSLog(@"NOT NİL.......");
}

[cell addSubview:webView];  


return cell;

}

由于您使用的是dequeueReusableCellWithIdentifier,因此每次显示单元格时都应重新配置单元格。 请记住,具有相同标识的单元格将被重复使用。最好为一种特定类型的单元设置相同的标识,通常是具有相同子视图和布局的单元

这是如何加载数据和重新配置单元的示例:

以下是熟悉UITableView的教程: