为什么我的appDelegate文件中“可能没有响应”?

时间:2010-08-06 12:51:38

标签: delegates

我正在尝试在我的appDelegate文件中调用一个方法,由于某种原因,我得到“appDelegate可能无法回复splashFade代码[self splashFade]

这是我的代码:


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch
    [window addSubview:mainController.view];
    [window makeKeyAndVisible];
    [Appirater appLaunched];
    [self splashFade];
    return YES;
}


- (void)splashFade {
    splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 768, 1024)];
    splashView.image = [UIImage imageNamed:@"Default-Portrait.png"];
    [window addSubview:splashView];
    [window bringSubviewToFront:splashView];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:window cache:YES];
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
    splashView.alpha = 0.0;
    [UIView commitAnimations];
}

- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
    [splashView removeFromSuperview];
}

谢谢!

1 个答案:

答案 0 :(得分:0)

您需要将其投射到AppDelegate -

YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.splashFade];