开发者

Why is my setImage line not working?

I have written 1 code for

-(IBAction)action:(UIEvent *)id
{

  [act setImage:[UIImage imageNamed:@"down.png"] forState:UIControlStateHighlighted];

}

It's working, but I have written 1 code for

-(IBAction)action:(UIEvent *)id
{

   [act setImage:[UIImage imageNamed:@"down.png"] forState:UIControlSta开发者_开发问答teHighlighted];

}

And after that I had written code for communication with server.

Now the setImage: line is not working.

What should I do?


The most likely explanation is that you did not get the outlet for the control that calls the action wired to the action in interface builder.

First, you should set a break point in the method to see if it even gets called. If it doesn't, check interface builder and hook up the proper connection. If it does get called, but the image is still not set, the problem is most likely that [UIImage imageNamed:@"down.png"] is returning a nil.


I think you are doing synchronous calling to server side code in the method and hence UI is not able to refresh properly. Use Asynchronous method to handle connection and it will work like a charm.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜