2012-05-31 70 views
0

我想在默认图像消失后在我的应用中插入启动动画。在我的应用程序,我有一个导航栏和标签栏,所以我试图把这个观点做了负载:iOS应用启动动画

UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myIMG.png"]]; 
[self.view addSubview:img]; 

然后,我想动画的形象与过渡,但与图像我定位在标签栏和导航栏之间的视图中,并且我希望所有图像都在前面开始动画。我怎样才能做到这一点?

回答

2

您应该:

  1. 创建一个视图控制器命名启动视图控制器。
  2. 在AppDelegate应用程序启动时,设置此视图为rootViewController
  3. 在加载数据或连接到服务器时,使用您的图像或任何想要的动作进行一些动画。
  4. 当这一切都完成后,从此启动视图控制器,您可以删除此启动视图,并通过调用应用程序委托来显示您的主视图,以设置您的主视图控制器是根视图控制器。

[编辑]

如果你只想要ImageView的可以覆盖所有的屏幕,那么你可以做如下:

[appDelegate.window addSubview:imageView]; 
+0

谢谢您的回答,但我认为我的马西德威控制器是显示在后台 – Piero

+0

如果你只想要ImageView的可以覆盖所有的屏幕,那么你可以做如下的动画过程中要: appDelegate.window addSubview:imageView]; –

0

最好的办法是创建一个Modal风格的细节,并用动画图像填充Segue的视图,并且在应用程序启动时,以编程方式立即调用该细分,因此它是第一个要出现。

0
[self.tabBarController.view addSubview:img]; 

然后您的图像将全屏显示。

2
  1. 为您开机动画
  2. 创建视图控制器
  3. 在应用程序委托中,显示您的启动视图控制器

在AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    .... 
    .... 
    .... 
    frontScreen *animScreen = [[frontScreen alloc] initWithNibName:@"frontScreen" bundle:nil]; 
    self.window.rootViewController = animScreen; 
    [self.window makeKeyAndVisible]; 
} 
  1. 成品动画之后,呼叫显示TabView的控制器

在frontScreen.m

AppDelegate* app =(AppDelegate*)[UIApplication sharedApplication].delegate; 
    [app afterAnimation]; 

在AppDelegate.m

-(void)afterAnimation { 
    rootController *list=[[rootController alloc] initWithNibName:@"rootController" bundle:nil]; 
    self.navigationController = [[UINavigationController alloc] initWithRootViewController:list]; 

    self.window.rootViewController = self.navigationController; 
    [self.window makeKeyAndVisible]; //optional 
    } 
+0

感谢您的回答,但我想在动画期间我的主视图控制器显示在后台 – Piero

2
//Display an Ads Imageview with animation on top of View 
imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sale2.jpg"]]; 
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDetected:)]; 
tapGesture.numberOfTapsRequired = 1; 
tapGesture.numberOfTouchesRequired = 1; 

[imageView addGestureRecognizer:tapGesture]; 
[imageView setUserInteractionEnabled:YES]; 
[imageView setMultipleTouchEnabled:YES]; 

[UIView animateWithDuration:3.5 animations:^{imageView.alpha = 0;imageView.alpha = 1;}]; 

[self.window addSubview:imageView]; 



-(void)tapDetected:(UIGestureRecognizer*)recognizer{ 
    //**************Remove the Advertising Image after the user press single tap on the img 
    [UIView animateWithDuration:1 animations:^{imageView.alpha = 1;imageView.alpha = 0;}]; 
}