我正在尝试从一些网址来制作一个动画。
我知道密码
animation.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"img-1.gif"],
[UIImage imageNamed:@"img-2.gif"],
[UIImage imageNamed:@"img-3.gif"],
[UIImage imageNamed:@"img-4.gif"],nil];
[animation setAnimationRepeatCount:3];
animation.animationDuration = 2;
[animation startAnimating];但是如何从服务器加载多张图片并使其具有动画效果呢?我有一个名为动画的Image View,有人能帮我举个例子吗?
发布于 2013-04-27 00:19:29
这是我用来做我的
我在我的viewDidLoad方法中完成了我的工作
//use your URL
NSData *picOne = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://sumptin.com/images/sumptin.jpg"]];
NSData *picTwo = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://sumptin.com/images/sumptin.jpg"]];
NSData *picThree = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://sumptin.com/images/sumptin.jpg"]];
NSData *picFour = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://sumptin.com/images/sumptin.jpg"]];
NSData *picFive = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://sumptin.com/images/sumptin.jpg"]];
//then convert data to actual pictures
UIImage *onePic = [UIImage imageWithData:picOne];
UIImage *twoPic = [UIImage imageWithData:picTwo];
UIImage *threePic = [UIImage imageWithData:picThree];
UIImage *fourPic = [UIImage imageWithData:picFour];
UIImage *fivePic = [UIImage imageWithData:picFive];
//then SHABAM!
slideShow.animationImages = [NSArray arrayWithObjects:
onePic,
twoPic,
threePic,
fourPic,
fivePic,
nil];
slideShow.animationDuration = 60.00f;
slideShow.animationRepeatCount = 0;
[slideShow startAnimating];我希望这个问题是在一年前发布的Helps...seeing :)
https://stackoverflow.com/questions/13352827
复制相似问题