我的应用程序中有一个 UIImageview,我想知道如何务实地在其中显示图像并随时更改它!我认为我的主要问题正是放在哪里!如果你能告诉我什么代码和在哪里那将非常有用!谢谢!
编辑:另外,如果您可以务实地将背景更改为图像甚至颜色!谢谢!要么或将工作!
EDIT2:这是我的代码,我不知道把它们放在哪里,因为它们总是给我一个错误!
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
和
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