アプリケーションに 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