Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
393 views
in Technique[技术] by (71.8m points)

iphone - UITableView Drawing Problems When ReloadData Is Called

I have a pretty large list of 'items' (up to 250 entries) which is constantly changing. The list is being displayed in a UITableView.

I have a polling thread that will download some new entries and insert them into a SQLite DB.

When new entries have arrived, I call to my table view data source object to update its data set, which runs a SQL query and returns a new array of entries.

After this is complete, I call -reloadData on the table view. When this happens, in about 7 out of 10 cases, the table view draws blank (no cells are displayed and only the background colour of the table is visible) until a subsequent -reloadData call is made. Touching the table view (scrolling, selecting a cell, anything that will force a redraw) will make it reappear.

The table view, its IBOutlet pointer and it's currently displayed cells are all valid at the times I see the blank drawing bug, so I'm fairly confident that they're not being released.

I've been trying to debug this for a few days now and it's really beginning to drive me up the wall.

Any help on this would be freaking awesome, thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Will it help if you do a [ myTable performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO] ?

The problem you mentioned can arise if you do not action your GUI updates from the main thread.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...