Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
472 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...