When I set the backgroundColor
for my UITableView
it works fine on iPhone (device and simulator) but NOT on the iPad simulator. Instead I get a lig
tried setting backgroundColor and View for the table, had no luck (Xcode 5 iOS7.1 iPad simulator), looked OK for iPhone, but light grey background color on iPad...
working with backgroundColor for the cell itself fixed this for me on iOS 7.1 4/2014
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ViewSomeTriggerCell";
// get a cell or a recycled cell
sictVCViewSomeTriggerCell *cellTrigger = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// put a picture and a word in the cell (positions set in .xib)
NSString * tname = [self.fetchedTriggersArray objectAtIndex:indexPath.row];
cellTrigger.imageTrigger.image = [UIImage imageNamed:@"icon_appicon.png"];
cellTrigger.labelName.text = tname;
// set background color, defeats iPad wierdness
// http://stackoverflow.com/questions/2688007/uitableview-backgroundcolor-always-gray-on-ipad
// clearColor is what I wanted, and it worked, also tested with purpleColor
cellTrigger.backgroundColor =[UIColor clearColor];
return cellTrigger;
}
I think it is worth noting that as of Xcode 6.1 and iOS 8.1, specifically for iPad (if you want to set cell background as well) it seems that you must set table background AND cell background.
For instance, on an iPhone storyboard you can set a cell to clear color, then set background image of table programmatically for a transparent table with background image. However if you were to view this same configuration on iPad the cells would not be clear. Cells will need to be set to clear programmatically for iPad.
None of the above worked for my UIViewController->UITableView specified using a single XIB. What did work was moving the whole setup into a Storyboard, and setting the background color using the IB inspector.