Вот в чем дело: я кодирую UIImageView в viewDidLoad, и я хочу, чтобы он двигался вниз с помощью моей кнопки fonctionPress **, не создавая другое подпредставление, как я.
Вот код.
- (void) viewDidLoad {
[super viewDidLoad];
banetteImage = [UIImage imageNamed: @ "myBanette.png"];
UIImageView *banetteView = [[UIImageView alloc] initWithImage:banetteImage];
banetteView.frame = CGRectMake(100, -740, 568, 790);
banetteView.opaque = NO;
[NSTimerscheduleTimerWithTimeInterval: 2.5 target: self selector: @selector (buttonPressed:) userInfo: nil повторяется: NO];
[self.view addSubview:banetteView];
}
- (void) кнопкаPressed {
double speed = 1 / round(random() % 100) + 1.0;
[UIView beginAnimations:nil context:banetteView];
[UIView setAnimationDuration: 2*speed ];
banetteView.frame = CGRectMake(100, -2, 568, 790);
banetteView.opaque = NO;
UIImageView *banetteView = [[UIImageView alloc] initWithImage:banetteImage];
banetteView2.frame = CGRectMake(100, -740, 568, 790);
banetteView.opaque = NO;
banetteView.hidden = YES;
[self.view addSubview:banetteView];
// set a stop callback so we can cleanup the banette when it reaches the
// end of its animation
[UIView setAnimationDidStopSelector:@selector(onAnimationComplete:finished:context:)];
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
}
- (void) onAnimationComplete: (NSString *) animationID закончено: (NSNumber *) завершено контекст: (пусто *) контекст {
UIImageView *banetteView = context;
double speed = 1 / round(random() % 100) + 1.0;
banetteView.frame = CGRectMake(100, -2, 568, 790);
banetteView2.opaque = NO;
[self.view addSubview:banetteView2];
[UIView beginAnimations:nil context:banetteView];
[UIView setAnimationDuration: 2*speed ];
[banetteView release];
}