开发者

Display an image on screen after button is pressed in Cocoa

I was wondering what I should use to display an image on screen every time the user presses a button. I am using Objective-C/CocoaTouch on the iPod Touch. I would like to pull these images from an array I have set up and place them on the screen when the button is triggered. I feel dumb asking but any one that can point me in the right direction would be great. I th开发者_运维问答ink I could figure out the rest from there.

Thanks.


I'm sure there are many ways of doing this, but one way would be to define a UIImageView on the screen, and make it hidden. When the user presses the button, you can set the source of the UIImageView to the image from your array, and set the hidden property to NO.


I think it's as simple as something like this:

[myImageView setImage:[imageArray objectAtIndex:theIndex]];

In your button's action method. You can set theIndex before or afterwards to get a different image from your array every time the action method gets called.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜