开发者

UILabel strange behaviour

i have this:

 - (IBAction)checkupdate
 { 
statusText.text = [[NSString alloc] initWithFormat:@"Checking......"];

everytime i press button, the string get display, ok no problem with that.

now when i add

NSURLRequest *theRequest = 
[NSURLRequest requestWithURL:
 [NSURL URLWithString:@"http:/myserver/version.plist"] 
                 cachePolicy:NSURLRequestUseProtocolCachePolicy
             timeoutInte开发者_如何学Pythonrval:5.0];    
NSURLResponse *response;
NSData *received = 
[NSURLConnection sendSynchronousRequest:theRequest 
                      returningResponse:&response error:&error];   

the string doesn't get display 1st. the NSURLRequest code is below the string display code all within the same action.

the string only display after the nsurlrequest is done.

isn't the displaying of the string suppose to execute 1st? i tried putting { , } to cover up the nsurlrequest, but still it get execute 1st.

any ideas?


The value of the label has been set but the redraw of the label can only be done when the function exits and it's not guaranteed to happen right at the exit. Since your making your request synchronously, it can take a long time before it is redrawn.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜