commitAnimations is not resizing my UIImageView subview
Posted
by AaronG
on Stack Overflow
See other posts from Stack Overflow
or by AaronG
Published on 2010-05-19T01:51:23Z
Indexed on
2010/05/19
2:00 UTC
Read the original article
Hit count: 320
I have created a UIView as a subview and to that subview I have added a UIImageView as a subview.
UIView *viewCreated;
UIButton *buttonCreated;
UIImageView *imageViewCreated;
CGRect myFrame = CGRectMake(0, 0, 1024, 1024);
viewCreated = [[UIView alloc] initWithFrame:myFrame];
[viewCreated setTag:intTag];
viewCreated.backgroundColor = [UIColor redColor];
[self.view addSubview:viewCreated];
[self randomize];
UIImage *d1Image = [UIImage imageNamed:[NSString stringWithFormat:@"image%d.png", randomNumber]];
imageViewCreated = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f,0.0f,1024.0f, 1024.0f)];
[imageViewCreated setImage:[UIImage imageNamed:[NSString stringWithFormat:@"image%d.png", randomNumber]]];
[viewCreated addSubview:imageViewCreated];
//[imageViewCreated release];
return [viewCreated autorelease];
But when this code executes only the first subview is animated and resized. The UiimageView moves 200 pixels to the left but does not get resized.
NSLog(@"sender tag %i",[sender tag]);
UIView *currentView = [self.view viewWithTag:[sender tag]];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5];
currentView.frame = CGRectMake(-200, 0,40, 102);
[UIView commitAnimations];
I am pretty sure am I not creating the subviews correctly programmatically, because when I do it in Interface Builder it works as expected.
Do I have to do something specific to actually attach the behavior of the second subview to the first subview?
© Stack Overflow or respective owner