Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 动画完成后设置新控制器_Ios_Objective C_Uinavigationcontroller - Fatal编程技术网

Ios 动画完成后设置新控制器

Ios 动画完成后设置新控制器,ios,objective-c,uinavigationcontroller,Ios,Objective C,Uinavigationcontroller,当应用程序启动时,第一个SplashScreen显示,并用于启动屏幕(用于动画目的),当动画完成时,应将其推到另一个MainViewController。 谁能告诉我代码中的错误在哪里,或者我如何解决这个问题 这是我的.h文件 #import <UIKit/UIKit.h> #import "SplashScreen.h" @interface AppDelegate : UIResponder <UIApplicationDelegate> { UIImage

当应用程序启动时,第一个
SplashScreen
显示,并用于启动屏幕(用于动画目的),当动画完成时,应将其推到另一个
MainViewController
。 谁能告诉我代码中的错误在哪里,或者我如何解决这个问题

这是我的.h文件

#import <UIKit/UIKit.h>
#import "SplashScreen.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
    UIImageView *splashView;
    }
@property (strong, nonatomic) UIWindow *window;

@end
尝试使用:


使用
-
[UIView animateWithDuration:…
代替旧式
[UIView beginAnimations:nil……
你能告诉我怎么做吗?因为我对ios比较熟悉。启动屏幕的代码运行成功,但在动画完成后,它不会移到secondviewcontroller上。我不反对,但我认为你的答案会更好,解释一下为什么这样做会比旧方法好。这主要是b因为他们是新来的,当有人解释一些东西而不是仅仅去这里的一些代码时,这总是很有帮助。我的问题不是制作动画视图,但我的问题是我不能在动画完成后推第二个视图。你能告诉我我应该在完成块中写些什么,这样我就可以推secnod viewcontroller了吗?我把您的代码在didfinishlaunch事件中但不工作。甚至动画也不工作。
splashView.frame
这可能会导致问题。请在调用块之前尝试定义帧。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    [_window addSubview:obj_SplashViewController.view];
    [_window makeKeyAndVisible];


    splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,480, 320, 50)];
    splashView.image = [UIImage imageNamed:@"icon_offer.PNG"];
    [_window addSubview:splashView];
    [_window bringSubviewToFront:splashView];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:4.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:_window cache:YES];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
    splashView.alpha = 0.0;
    splashView.frame = CGRectMake(0, 100, 320, 50);
    [UIView commitAnimations];

    return YES;
}




- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
    [splashView removeFromSuperview];
    MainViewController *obj_MainViewController = [[MainViewController alloc]init];
    [self.window setRootViewController:obj_MainViewController];
}
  [UIView animateWithDuration:.3
                         animations:^{
                         splashView.alpha = 0.0;
                         splashView.frame = CGRectMake(0, 100, 320, 50);
                         }
                         completion:^(BOOL finished){
                             NSLog(@"completion block");
                              [splashView removeFromSuperview];
                               MainViewController *obj_MainViewController = [[MainViewController alloc]init];
                              [self.window setRootViewController:obj_MainViewController];
                         }];
    }