load animationImage from a table view Controller
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]
精彩评论