Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yoavhorev

macrumors newbie
Original poster
Jul 11, 2009
1
0
Hi,
I tried to add a UIImageView to my UIViewController but it doest seems to work. I dont know if what I am doing is the best way to go but what I am trying to achieve is to have a bit f text, a few buttons and an image all displayed on the same screen.
in the .h file I wrote:

#import <UIKit/UIKit.h>

@class HelloUniverseController;

@interface HelloUniverseAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
HelloUniverseController *hvController;
UIImageView *image;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) HelloUniverseController *hvController;
@property (nonatomic, retain) UIImageView *image;

@end

in the .m I wrote:

#import "HelloUniverseAppDelegate.h"

@implementation HelloUniverseAppDelegate

@synthesize window, hvController, image;


- (void)applicationDidFinishLaunching:(UIApplication *)application {

HelloUniverseController *hvc = [HelloUniverseController alloc];
hvc = [hvc initWithNibName:mad:"HelloUniverse" bundle:[NSBundle mainBundle]];

self.hvController = hvc;


[hvc release];

[window addSubview:[self.hvController view]];


UIImageView *img = [[UIImageView alloc] imageNamed:mad:"Picture.png"];


self.image = img;

[img release];

[self.hvController addSubview:[(self.image) view]];



// Override point for customization after application launch
[window makeKeyAndVisible];
}


- (void)dealloc {
[hvController release];
[window release];
[super dealloc];
}


@end

the UIViewController works just fine, I just cant get the picture to work.
Thanks
Yoav.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
This line:

UIImageView *img = [[UIImageView alloc] imageNamed:mad:"Picture.png"];

Appears to be totally wrong. You need an init or initWithXXX method (probably initWithImage:). Don't try and make up methods: read the documentation!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.