UITableView backgroundColor always gray on iPad

前端 未结 9 1467
小蘑菇
小蘑菇 2020-11-30 18:02

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

9条回答
  •  没有蜡笔的小新
    2020-11-30 18:54

    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;
    

    }

提交回复
热议问题