アプリの最初に簡単なアニメーションがあります。
起動時に画面外でアニメーション化されるメインビュー上にUIViewが表示されます。メインビューが読み込まれるたびではなく、アプリの起動時にのみアニメーション化する必要があります。私の問題は、私のコードを使用して、必要に応じてアニメーションを停止できることですが、メインビューをロードすると、ビューをオーバーレイする最初の状態に戻ります。
要約すると、UIviewを画面外でアニメーション化し、アプリが再起動されるまでそこにとどまるようにします。アドバイスをいただければ幸いです
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(performAnimation:) name:UIApplicationDidBecomeActiveNotification object:nil];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
[self setDoorbottom:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (IBAction)alert:(id)sender {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"" delegate:nil cancelButtonTitle: @"Dismiss" otherButtonTitles: nil];
[alert show];
}
- (void)performAnimation:(NSNotification *)aNotification {
// Animation code.
CGRect doorbottomFrame = doorbottom.frame;
doorbottomFrame.origin.y = self.view.bounds.size.height;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
doorbottom.frame = doorbottomFrame;
[UIView commitAnimations];
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"Air", CFSTR
("wav"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID (soundFileURLRef, &soundID);
AudioServicesPlaySystemSound (soundID);
}
@end