Проблема с анимацией uiimageView с массивом - PullRequest
0 голосов
/ 24 июля 2011

вот мой код:

-(void) createNewImage {


UIImage * image = [UIImage imageNamed:@"abouffer_03.png"];
imageView = [[UIImageView alloc] initWithImage:image];

[imageView setCenter:[self randomPointSquare]];

 [imageViewArray addObject:imageView];

[[self view] addSubview:imageView];

[imageView release];


}



-(void)moveTheImage{
for(int i=0; i< [imageViewArray count];i++){
    UIImageView *imageView = [imageViewArray objectAtIndex:i];
    imageView.center = CGPointMake(imageView.center.x + X, imageView.center.y + Y);
}



}



- (void)viewDidLoad {
[super viewDidLoad];

[NSTimer scheduledTimerWithTimeInterval:4 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(onTimer2)];
[displayLink setFrameInterval:1];
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];


imageViewArray = [[NSMutableArray alloc]init];
}

Моя проблема в том, что каждые четыре секунды создается новый «imageView», и в течение четырех секунд он перемещается, затем создается новый «imageView» и перемещается в другом направлении, а предыдущий «imageView» следует этому последнему они движутся в одном направлении, и это происходит каждые четыре секунды. Как я могу решить это, пожалуйста?

Мне кажется, проблема в массиве.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...