iphone - UIImageView alloc] initWithImage using IBOutlet not working -



iphone - UIImageView alloc] initWithImage using IBOutlet not working -

i've typically followed pattern of creating object in method (like viewdidload), have property hold onto it, release original object created. this:

nsarray *myarray = [nsarray alloc] initwithobjects:@"1", @"2", @"3", nil]; self.array = myarray; [myarray release];

i thought same thing uiimageview. have uiimageview created in .xib. have outlet property so

@property (nonatomic, retain) iboutlet uiimageview *imageview;

in viewdidload, do:

uiimageview *imgview = [[uiimageview alloc] initwithimage;[uiimage imagenamed:@"arrow.png"]]; self.imageview = imgview; [imgview release];

if run this, not on screen. however, if in viewdidload instead:

[self.imageview setimage:[uiimage imagenamed:@"arrow.png"]];

i arrow image on screen. there different uiimageview missing here?

edit because of first response: uiimageview different uitableview in need add together subview current view? when create uitableview in ib, not add together subview in viewdidload.

thanks.

you missing point behind how iboutlet work. if specified in .xib allocated :) utilize it.

hence [self.imageview setimage:[uiimage imagenamed:@"arrow.png"]]; works since assigned image it.

however, when doing

uiimageview *imgview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"arrow.png"]]; self.imageview = imgview; [imgview release];

you deallocated imageview instance created ib @ self.imageview = imgview; line , set new 1 , neither did added subview anything. since new instance need added !! anyways approach wrong if using iboutlet

iphone uiimageview

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -