1
我是新iPhone編程,我無法改變我的表視圖單元格的背景的UITableView:無法更改單元格的顏色
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
if((indexPath.row%2)!=0)
{
[cell setBackgroundColor:[UIColor clearColor]];
[cell setBackgroundColor:[UIColor redColor]];
//[cell ];
}
else
{
[cell setBackgroundColor:[UIColor whiteColor]];
}
}
// Configure the cell...
[cell setText:[menuItems objectAtIndex:indexPath.row]];
return cell;
}
請幫助我瞭解爲什麼??
Thanx提前