I have a UIImageview in my application and I was wondering how I can show an image in it pragmatically and change it whenever I want to! I think my major problem is exactly WHERE to put it! If you could show me what code and where that would be very usefull! thanks!
EDIT: Also if you can pragmatically change the background into an image or even a color! thanks! either or will work!
EDIT2: here is my code, i dont know where to put those because they always give me an error!
MainView.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface MainView : UIView {
//static int r;
int r;
IBOutlet UIButton *myButton;
IBOutlet UILabel *myTextLabel;
IBOutlet UILabel *myTextLabel2;
IBOutlet UIImageView *myImage;
}
@property (nonatomic, retain) UIButton *myButton;
@property (nonatomic, retain) UILabel *myTextLabel;
@property (nonatomic, retain) UILabel *myTextLabel2;
@property (nonatomic, retain) UIImageView *myImage;
- (IBAction)buttonclick;
//+(void) initialize;
@end
and the
MainView.m
#import "MainView.h"
#include <stdlib.h>
#include <libc.h>
@implementation MainView
@synthesize myButton, myTextLabel, myTextLabel2, myImage;
- (IBAction)buttonclick {
r++;
if(r == 1) {
self.myTextLabel.text = @"word";
self.myTextLabel2.text = @"def.";
}else if(r == 2) {
self.myTextLabel.text = @"word2";
self.myTextLabel2.text = @"def2 ";
}
}
@end