普通にぴっとおきたいところですが、IBさんと縁を切るとそうも簡単にいかないものです。
別れて初めて分かる、ありがたさ。。。
ということで、まず仕組みからです。
画像をおくときhoge.jpgとかhoge.pngとかまぁなんでもいいんですが、
それをおくための枠が必要になります。しかも枠の枠のみたいな。
UIView → UIImageView → UIImage(ここでhoge.pngとか指定)
めんどくさいですよね。が、あとあと指定して消したり何ダリ便利なので
覚えるかー。
■.hさん
@interface ViewControllerhoge : NSObject
UIWindow *window;
IBOutlet UIView* hogeview;
IBOutlet UIImageView *hogeimageview;
IBOutlet UIImage *hogeimage;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property(nonatomic,retain) IBOutlet UIView* hogeview;
@property(nonatomic,retain) IBOutlet UIImageView *hogeimageview;
@property(nonatomic,retain) IBOutlet UIImage *hogeimage;
@end
■.mさん
#import "ViewControllerhoge.h"
@implementation ViewControllerhoge;
@synthesize hogeview,hogeimageview,hogeimage;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window makeKeyAndVisible];
hogeview = [[UIView alloc] init];
hogeview.frame = self.window.bounds;
hogeview.backgroundColor = [UIColor whiteColor];
[self.window addSubview:hogeview];
hogeimage = [UIImage imageNamed:[NSString stringWithFormat:@"hoge.jpg"]];
hogeimageview = [[UIImageView alloc] initWithImage:hogeimage];
[hogeview addSubview:hogeimageview];
return YES;
}
- (void)dealloc {
[window release];
[hogeview release];
[hogeimageview release];
[hogeimage release];
[super dealloc];
}
@end
と書きます。それで、Xcode上でResourcesフォルダを開き、そこにhoge.jpgを
ドラッグしておっことせば完了ですー。ポイ。
