UITableviewCell 值正在改变
UITableviewCell values are changing
我是 iPhone 开发新手。我正在使用 UItableview 显示列表。
并能够成功显示所有项目。
但是当我滚动 tableview 时它们发生了变化。
请帮帮我
请给我更多信息,以便清楚地展示您的案例。
先看看这个函数,因为所有的行都是从这里生成的!
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
静态 NSString *simpleTableIdentifier = @"SimpleTableCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
如果(单元格==无){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [食谱objectAtIndex:indexPath.行];
return 单元格;
}
检查每一行是否存在,除非稍后再使用它。
在 tableview 的 cellForRowAtIndexPath 方法中尝试此代码
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
我是 iPhone 开发新手。我正在使用 UItableview 显示列表。 并能够成功显示所有项目。 但是当我滚动 tableview 时它们发生了变化。
请帮帮我
请给我更多信息,以便清楚地展示您的案例。 先看看这个函数,因为所有的行都是从这里生成的!
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 静态 NSString *simpleTableIdentifier = @"SimpleTableCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
如果(单元格==无){ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier]; }
cell.textLabel.text = [食谱objectAtIndex:indexPath.行]; return 单元格; }
检查每一行是否存在,除非稍后再使用它。
在 tableview 的 cellForRowAtIndexPath 方法中尝试此代码
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}