Hi,
its possible to reload a image when i switch to a view again?
Because the image displayed after 5seconds. But when I again switch to the view, only the sound plays but not the image is showing!
Should i have to do that with the method viewDidDisappear?
Code:
- (void)showImage {
UIImage *hintergrund = [UIImage imageWithData: [[NSUserDefaults standardUserDefaults] objectForKey: @"UserDefinedImage"]];
if (!hintergrund) hintergrund = [UIImage imageNamed: @"scaryface.png"];
faceView.image = hintergrund;
[UIView beginAnimations:nil context:faceView];
[UIView setAnimationDelay:0.5];
[UIView setAnimationDuration:0.25];
[faceView setAlpha:0.0];
[UIView commitAnimations];
CFBundleRef mainBundle;
mainBundle = CFBundleGetMainBundle ();
soundFileURLRef = CFBundleCopyResourceURL (mainBundle,CFSTR ("schrei"),CFSTR ("aif"), FALSE);
AudioServicesCreateSystemSoundID (soundFileURLRef,&soundFileObject);
AudioServicesPlaySystemSound (self.soundFileObject);
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
[[NSUserDefaults standardUserDefaults] removeObjectForKey: @"UserDefinedImage"];
[[NSUserDefaults standardUserDefaults] synchronize]; // Sofort löschen + Speicher freimachen
}
- (void)viewWillAppear:(BOOL)animated {
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"ShowScaryFace"])
[self performSelector:@selector(showImage) withObject:nil afterDelay:5.0];
[super viewWillAppear:animated];
}
thnaks!