开发者

UITableView Redraw Problems

I have a UITableView that is showing some very strange behavior when reloading it. For some reason, some of the borders of the table view just go missing (even though I never modified them), but the cell labels shown are correct.

If I just reload a single row, this row looses its borders. If I reload the entire table, the entire table looses its borders.

I am using a white background and the cells have a white background also while the UITableView uses a gro开发者_开发百科up style.

I haven't seen such behavior before - is this a bug?

Here's how I setup the table:

settingsController.view.backgroundColor = [UIColor whiteColor];

_settingsTable = [[UITableView alloc] initWithFrame:[UIApplication sharedApplication].keyWindow.frame style:UITableViewStyleGrouped];
_settingsTable.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_settingsTable.delegate = self;
_settingsTable.dataSource = self;
_settingsTable.backgroundView = nil;

[settingsController.view addSubview:_settingsTable];

and the cells are turned white via this simple code:

cell.backgroundView = nil;
cell.backgroundColor = [UIColor whiteColor];

UITableView Redraw Problems

As you can see from the screenshot above, the volume cell lost its borders after having reloaded the cell. Does anyone know what's going on?

Edit: Here's how I solved this:

There appears to be a bug in UITableView. As you may be aware, UITableView does not care about the backgroundColor property because its background is loaded in a separate view which by default is a textured image. By setting this to null, the table view showed display errors.

I fixed this by just creating a separate white view - now it works fine.

UIView*whiteBg = [[UIView alloc] initWithFrame:_settingsTable.frame];
whiteBg.backgroundColor = [UIColor whiteColor];

_settingsTable.backgroundView = whiteBg;

[whiteBg release];


Dont' set the background view of your table to nil. A similar effect can be achieved by setting the backgroundColor to [UIColor clearColor]

Same applies to UITableViewCell.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜