开发者

load animationImage from a table view Controller

开发者 https://www.devze.com 2022-12-17 05:20 出处:网络
I use a UITableViewController to display a list of items, and one of the items selection must lead to a

I use a UITableViewController to display a list of items, and one of the items selection must lead to a photo gallery created with animationImages. I usually declare the controllers associated to the first level selection w开发者_Python百科ith something like :

MyController *myController = [[MyController alloc] initWithStyle:UITableViewStylePlain];

myController.title = @"title 1";

myController.rowImage = [UIImage imageNamed:@"myControllerIcon.png"];

..

But I believe a UIViewController is needed to use animationImages.. How can I display a image animation directly from a table view ?


If you have you image sequence build in this manner:

NSArray *myImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"myImage1.png"],
[UIImage imageNamed:@"myImage2.png"],
[UIImage imageNamed:@"myImage3.png"],
[UIImage imageNamed:@"myImage4.gif"],
nil];

UIImageView *myAnimatedView = [UIImageView alloc];
[myAnimatedView initWithFrame:[self bounds]];
myAnimatedView.animationImages = myImages;
myAnimatedView.animationDuration = 0.25; // seconds
myAnimatedView.animationRepeatCount = 0; // 0 = loops forever
[myAnimatedView startAnimating];
[self addSubview:myAnimatedView];
[myAnimatedView release];

Snatched from here

Then you can build your own cell or add the animationImage to the cell by adding it to either:

[cell setImage:myAnimatedView];
[cell setBackgroundView:myAnimatedView];
[cell setSelectedBackgroundView:myAnimatedView]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号