J'ai un problème avec mon animation d'image.problème avec l'animation de l'image
ici est le .h
@interface Flash_ViewController : UIViewController {
IBOutlet UITextField *textField;
IBOutlet UIButton *generateFlash;
IBOutlet UIImageView *theFlash;
IBOutlet UILabel *testLabel;
NSArray *letterArray;
NSMutableArray *imageArray;
NSTimer *myTimer;
int runLoopTimes;
int indexTimes;
}
-(IBAction) generateFlashNow:(id)sender;
@end
ici est le .m
-(IBAction) generateFlashNow:(id)sender{
[textField resignFirstResponder];
/*
NSString *string1 = textField.text;
//NSString *string2 = [string1 stringByReplacingOccurrencesOfString:@"" withString:@","];
NSArray *arrayOfLetters = [string1 componentsSeparatedByString:@","];
*/
NSString *string = textField.text;
NSMutableArray *arrayOfLetters = [[NSMutableArray alloc] init];
for(int i = 0; i < [string length]; i++) {
NSString *myChar = [NSString stringWithFormat:@"%c", [string characterAtIndex:i]];
[arrayOfLetters addObject:myChar];
}
NSLog(@"Log Array :%@", arrayOfLetters);
//NSArray *imageArray = [[NSArray alloc] init];
NSLog(@"Log First Letter of array: %@",[arrayOfLetters objectAtIndex:0]);
runLoopTimes = [arrayOfLetters count];
NSLog(@"Letters:%d", runLoopTimes);
while (runLoopTimes > 0) {
NSLog(@"loopedy Loop");
NSString *LetterString = [NSString stringWithFormat:@"%@", [arrayOfLetters objectAtIndex:indexTimes]];
runLoopTimes --;
NSLog(@"letter String : %@", LetterString);
NSString *imageName = [LetterString stringByAppendingString:@".png"];
NSLog(@" IMAGE NAME: %@", imageName);
[imageArray addObject:[UIImage imageNamed:imageName]];
NSLog(@"Added object %d", indexTimes);
testLabel.text = LetterString;
indexTimes ++;
}
NSLog(@"done");
runLoopTimes = 0;
indexTimes = 0;
[arrayOfLetters autorelease];
[theFlash setAnimationImages:imageArray];
[theFlash setAnimationRepeatCount:1];
theFlash.animationDuration = 4;
[theFlash startAnimating];
NSLog(@"images flashed");
}
et je fais indexTimes = 0; dans la méthode viewDidLoad. Mes connexions sont faites dans IB, et tous les messages de journal se déclenchent. Mais, je ne vois toujours pas d'animation. Qu'est-ce que je fais mal?
Toutes les idées seraient appréciées.
Merci, Sam
Il est difficile de dire à partir du code que vous avez posté ce qui ne va pas. Nous devrions en savoir plus sur ce que vous avez fait dans le constructeur d'interface (ce qui n'est pas facile à poster ici ...). Etes-vous sûr que theFlash est ajouté à une sous-vue et est visible? –