objective c - iPhone: Screen not redrawing when I do something heavy _afterwards_ -


i want post message , picture twitter (using picture hoster). if user enters message alone , taps send overlay appears , shows "sending message twitter". if user adds picture doesn't show overlay. maybe because has convert jpg , thats heavy load? code looks this:

[overlaymessage changetextto:nslocalizedstring(@"keysendtwitter", nil)]; overlaymessage.hidden = no;  overlaymessage.locked = yes;  // i've added these out of desperation :p [overlaymessage setneedsdisplay]; [self.view setneedsdisplay];  [self sendmessage]; 

it seems 2 messages (changetextto: , sendmessage:) running in parallel , sendmessage little bit faster doing heavy loading. require threading , app not multithreaded.

or maybe setneedsdisplay: wrong message update screen before heavy loading?

not 100% clear you're doing, sounds [self sendmessage] method blocking ui updating. makes sense if you're doing large synchronous network operation or image conversion. don't have mess around threading ui responsive during heavy operations. call sendmessage on different thread with:

[self performselector@selector(sendmessage) withobject:nil afterdelay:0.001f]; 

or

[self performselectorinbackground:@selector(sendmessage) withobject:nil]; 

your method end, ui update (no need setneedsdisplay, probably) , sendmessage selector fire. in charge of making sure sendmessage causes loading screen dismissed, you'll think of :)

the key idea here interface updates happen in batches. bit of code runs, , interface updates... bit of code runs, , interface updates.

what's happening here code bulky, , ui can't update until it's done. calling setneedsdisplay marks view "dirty" , in need of redrawing, doesn't re-draw view.

i suggest either break operation asynchronous chunks, use nsoperationqueue, or use 1 of performselector variants.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -