【发布时间】:2011-08-13 06:17:10
【问题描述】:
在 UIViewController 内部,tempview2 根本没有出现。只有 tempview 出现。
-(id)初始化:(NSData *)图像数据 { if ((self = [super init])) { tempimage= [[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"pic1" ofType:@"png"]] autorelease]; tempview=[[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease]; [临时视图集图像:临时图像]; [self.view addsubview tempview]; } 回归自我; } -(无效)viewdidload{ tempimage2= [[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"pic2" ofType:@"png"]] autorelease]; tempview2=[[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease]; [tempview2 setImage:tempimage2]; [self.view addsubview tempview2]; }如果我这样做,那么一切都好,
-(id)初始化:(NSData *)图像数据 { if ((self = [super init])) { tempimage= [[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"pic1" ofType:@"png"]] autorelease]; tempview=[[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease]; [临时视图集图像:临时图像]; [self.view addsubview tempview]; tempimage2= [[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"pic2" ofType:@"png"]] autorelease]; tempview2=[[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease]; [tempview2 setImage:tempimage2]; [self.view addsubview tempview2]; } 回归自我; }【问题讨论】:
标签: iphone