UILabel in UITable do not get display but get disp

2019-06-13 20:38发布

问题:

  1. Referring Image number 1: In ios 6 and 5, the label get display properly in UItable.

  2. Referring Image number 2: In IOS 7, the label do not get display in UItable.

  3. Referring Image number 3: In iOS 7, the label get display on click of cell in UItable.

  4. Below is the code used to write cell in UItable.

    -(UILabel *)createLabel:(UILabel *)sender1 :(int)x :(int)y :(NSString *)title :(int)size :(int)swidth :(int)ht
       {
         sender1 = [[UILabel alloc] initWithFrame:CGRectMake(x, y, swidth, ht)];
         sender1.text = title;
         [sender1 setTextColor:[UIColor whiteColor]];
         [sender1 setBackgroundColor:[UIColor clearColor]];
         [sender1 setFont:[UIFont systemFontOfSize:size]];
         sender1.numberOfLines = 2;  //7
    
         sender1.lineBreakMode = NSLineBreakByWordWrapping;
         sender1.contentMode = UIControlContentVerticalAlignmentCenter;
    
        return sender1;
      }
    

    I am sure it is not simulator issue.

回答1:

  1. The issue was with the default background colour of the cell.
  2. In Ios 6 and 5 it use to set black but in Ios 7 it is set to White.

    [cell setBackgroundColor:[UIColor blackColor]]; is the solution.