添加动画在启动时使用图像阵列 [英] Adding animation at start up using an array of images

查看:94
本文介绍了添加动画在启动时使用图像阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的iPhone应用程序开发和我试图将图像添加到我的应用程序的开始。我创建图像的数组,迭代应该创建一个动画的时候。

I'm new to iphone app development and I'm trying to add an image to the start of my app. I've created an array of images which when iterated should create an animation.

-(void)viewDidLoad
{

    animation = [[UIImageView alloc] init];
    animation.animationImages = [NSArray arrayWithObjects: 
                                                 [UIImage imageNamed:@"panda1.png"],                                  
                                                 [UIImage imageNamed:@"panda2.png"],                              
                                                 [UIImage imageNamed:@"panda3.png"], nil];

    animation.animationRepeatCount = 2;
    animation.animationDuration = 2;
    [animation startAnimating];

    [self.view addSubview:animation];

    [animation release];

    //for loading the webpage at start up

    NSString *urlAddress = @"http://projects.seng.uvic.ca/fatpanda/m/most_recent.php";
    NSURL *url = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

    //load the request in the UIWebView
    [webView loadRequest:requestObj];   
}

我释放动画在本月底的原因是因为我想删除最后一个图像,所以我可以在一个UIWebView一个网站的视图替换它,并有在年底可见。在code以上编译,但是当我运行它不显示图像,但该网站一样。

The reason I release the animation at the end of this is because I'd like to remove the last image so I can replace it with a view of a website in a UIWebView and have that visible at the end. The code above compiles but when I run it no images appear but the website does.

任何帮助将大大AP preciated。

Any help would be greatly appreciated.

推荐答案

试试这个,我觉得你的帧结束了全零。

try this, i think your frame is ending up all zeros.

UIImage * first = [UIImage imageNamed:@"panda1.png"]
animation = [[UIImageView alloc] initWithImage:first];
animation.animationImages = [NSArray arrayWithObjects: 
                                             first,                                  
                                             [UIImage imageNamed:@"panda2.png"],                              
                                             [UIImage imageNamed:@"panda3.png"], nil];

另外...
释放animaiton不会从上海华移除。其实调用addSubview将增加引用计数到的UIImageView和释放是做正确的事。当你想从视图删除它,你会在子视图列表都找了一遍,要么隐藏或致电removeFromSuperview。

Also... releasing the animaiton will not remove it from the superview. in fact calling addSubview will increase the reference count to the UIImageView and releasing it is the correct thing to do. When you want to to remove from the view it you will have to find it again in the list of subviews and either hide it or call removeFromSuperview.

这篇关于添加动画在启动时使用图像阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆