Iphone tableview单元格样式有问题-UITableViewCellStyleValue1
我正在使用表视图显示列表。只有一个单元格将具有Iphone tableview单元格样式有问题-UITableViewCellStyleValue1,iphone,tableview,Iphone,Tableview,我正在使用表视图显示列表。只有一个单元格将具有UITableViewCellStyleValue1。问题是,当上/下滚动时,详细文本显示不好。这是密码 // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString
UITableViewCellStyleValue1
。问题是,当上/下滚动时,详细文本显示不好。这是密码
// 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) {
if(indexPath.row == 0)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
cell.textLabel.textColor = [UIColor whiteColor];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.detailTextLabel.textColor = [UIColor yellowColor];
cell.detailTextLabel.text = @"Description";
}
else
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.textLabel.textColor = [UIColor whiteColor];
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
// Configure the cell.
cell.textLabel.text = [radioList objectAtIndex:indexPath.row];
return cell;
}
//自定义表格视图单元格的外观。
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
静态NSString*CellIdentifier=@“Cell”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
如果(单元格==nil){
if(indexPath.row==0)
{
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1重用标识符:CellIdentifier]自动释放];
cell.textLabel.textColor=[UIColor whiteColor];
cell.accessoryType=UITableViewCellAccessoryDetailDisclosure按钮;
cell.detailtextlab.textColor=[UIColor yellowColor];
cell.detailTextLabel.text=@“说明”;
}
其他的
{
cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:CellIdentifier]自动释放];
cell.textLabel.textColor=[UIColor whiteColor];
cell.accessoryType=UITableViewCellAccessoryNone;
}
}
//配置单元格。
cell.textlab.text=[radioList objectAtIndex:indexath.row];
返回单元;
}
有人能帮我吗?您没有正确处理单元重用。试着这样做,我想你应该能够看到我做的不同
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
if(indexPath.row == 0)
{
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier2] autorelease];
}
cell.textLabel.textColor = [UIColor whiteColor];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.detailTextLabel.textColor = [UIColor yellowColor];
cell.detailTextLabel.text = @"Description";
}
else
{
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.textColor = [UIColor whiteColor];
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
// Configure the cell.
cell.textLabel.text = [radioList objectAtIndex:indexPath.row];
return cell;
}