Возникла проблема с addubview для viewdidload

] внутри UIViewController, tempview2 вообще не отображается. отображается только tempview.

        
-(id) init:(NSData*) imageData
{
    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];
        [tempview setImage:tempimage];
        [self.view addsubview tempview];
}
 return self;

}

    -(void) 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) init:(NSData*) imageData
{
    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];
        [tempview setImage:tempimage];
        [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];
}
 return self;

}

0
задан lilzz 26 April 2011 в 18:15
поделиться