我有一个动画(目前30个不同的图像重复),我想把它添加到一个单一的滚动视图页面(目前持有7页)。能做到吗?
addAnimation
我看不到的方法。有人能看看这个告诉我我做错了什么吗。。。恐怕这是个明显的错误,我已经盯着这个看了一段时间了。
- (void)loadView {
pageArray = [[NSMutableArray alloc] init];
[self setUpView];
}
- (void)setUpView {
CGRect pagingScrollViewFrame = [[UIScreen mainScreen] bounds];
pagingScrollViewFrame.origin.x = 0;
pagingScrollView = [[UIScrollView alloc] initWithFrame:pagingScrollViewFrame];
pagingScrollView.contentMode = UIViewContentModeScaleAspectFit;
pagingScrollView.pagingEnabled = YES;
pagingScrollView.backgroundColor = [UIColor whiteColor];
pagingScrollView.contentSize = CGSizeMake(pagingScrollViewFrame.size.width*7, pagingScrollViewFrame.size.height);
self.view = pagingScrollView;
for (int i = 0; i < 7; i++){
ImageScrollView *page = [[[ImageScrollView alloc] init] autorelease];
[self configurePage:page forIndex:i];
[pagingScrollView addSubview:page];
[pageArray addObject:page];
}
}
- (void)configurePage:(ImageScrollView *)page forIndex:(NSUInteger)index
{
page.index = index;
page.frame = [self frameForPageAtIndex:index];
if (index == 4){
[self addAnimation:page];
}else {
[page displayImage:[self imageAtIndex:index]];
}
}
- (void)addAnimation:(ImageScrollView *)page{
UIImageView* animationView = [[UIImageView alloc] init];
animationView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"pin clip0000.jpg"],
[UIImage imageNamed:@"pin clip0001.jpg"],
[UIImage imageNamed:@"pin clip0002.jpg"],
[UIImage imageNamed:@"pin clip0003.jpg"],
[UIImage imageNamed:@"pin clip0004.jpg"],
[UIImage imageNamed:@"pin clip0005.jpg"],
[UIImage imageNamed:@"pin clip0006.jpg"],
[UIImage imageNamed:@"pin clip0007.jpg"],
[UIImage imageNamed:@"pin clip0008.jpg"],
[UIImage imageNamed:@"pin clip0009.jpg"],
[UIImage imageNamed:@"pin clip0010.jpg"],
[UIImage imageNamed:@"pin clip0011.jpg"],
[UIImage imageNamed:@"pin clip0012.jpg"],
[UIImage imageNamed:@"pin clip0013.jpg"],
[UIImage imageNamed:@"pin clip0014.jpg"],
[UIImage imageNamed:@"pin clip0015.jpg"],
[UIImage imageNamed:@"pin clip0016.jpg"],
[UIImage imageNamed:@"pin clip0017.jpg"],
[UIImage imageNamed:@"pin clip0018.jpg"],
[UIImage imageNamed:@"pin clip0019.jpg"],
[UIImage imageNamed:@"pin clip0020.jpg"],
[UIImage imageNamed:@"pin clip0021.jpg"],
[UIImage imageNamed:@"pin clip0022.jpg"],
[UIImage imageNamed:@"pin clip0023.jpg"],
[UIImage imageNamed:@"pin clip0024.jpg"],
[UIImage imageNamed:@"pin clip0025.jpg"],
[UIImage imageNamed:@"pin clip0026.jpg"],
[UIImage imageNamed:@"pin clip0027.jpg"],
[UIImage imageNamed:@"pin clip0028.jpg"],
[UIImage imageNamed:@"pin clip0029.jpg"],
nil];
animationView.animationDuration = 1;
animationView.animationRepeatCount = 0;
[animationView startAnimating];
[page addSubview:animationView];
[animationView release];
}