开发者

Getting UIImageView to Change its Image IPhone App

Still a newbie here, forgive me. I'm trying to make a button that will change an Image thats located in the same view.

- (IBAction)myButton:(id)sender {  
    myUIImageView.image = [UIImage imageNamed:@"image.jpg"];
}

And I synthesize myUIImageView above this. I have also created it in the .h file:

- (IBAction)myButton;
@property(retain, nonatomic) IBOutlet UIImageView* myUIImageView;

I have created a button called myButton in IB. Connected it's Touch Up Inside event to File's Owner. I've connected to the UIImageView with File's Owner. Also, I have image.jpg in开发者_开发知识库side my resources folder, however the image stays the same when I push the button. Nothing happens! The app loads fine with no errors, any advice would help,

Thanks!


Put an NSLog statement inside of your IBAction to make sure that you have properly connected to the action. Also make sure that you have the same signature for your IBAction in your header file and implementation file. Right now one of them is

- (IBAction)myButton;

and the other is

- (IBAction)myButton:(id)sender

Make sure that they both have the same signature.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜