I have a UITableView in my app. Everything works fine until I put this code below in the
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//this is the code that causes the problem.
UIView *blackBGView = [[UIView alloc] init];
blackBGView.backgroundColor = [UIColor blackColor];
cell.backgroundView = blackBGView;
The problem is that the background doesn’t appear until you click the uitableview anywhere. Then after that it works only some of the time. The background view is just really glitchy.
What am I doing wrong?
Define in
blackBGViewyour header, then call the following code in yourviewDidLoad:Then in
cellForRowAtIndexPath:you can call:However, I am not sure why you are adding a UIView to your cell, when you can just call: