需要帮助确定动画中显示的图像

时间:2012-05-21 00:38:18

标签: ios animation uiimageview

  

可能重复:
  Fetching image From Animating UIImageView

我在这里遇到一些问题,并且认为我会请求你的协助。

我有一个具有表视图的应用程序,并将在页脚的UIImageView中为表视图的每个字母部分显示一个横幅。每个页脚都是动画的,并且每五秒钟会显示一个特定的图像,具体取决于数组中命名的下一个图像。我的目标是,如果用户点击该页脚,他们将转到不同的页面,具体取决于收到触摸时显示的图像。我已经能够动画图像,并通过重载UIImageView类(bannerView)和实现touchesBegan函数来接收触摸。我的问题是确定显示哪个图像,所以我知道要去哪里。有什么方法可以确定吗?以下是viewForFooterInSection的代码:

 -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section {
UIView *footer;
NSArray *uniqueArray = [[NSArray alloc] init];
NSMutableArray *animationArray = [[NSMutableArray alloc] init];

categoryViewController *myArray = [[categoryViewController alloc] init];

NSArray *bannerArrayFromDictionary = [[NSArray alloc] init];
bannerArrayFromDictionary = [bannerDictionary objectForKey:[NSNumber numberWithInt:section]];

if (bannerArrayFromDictionary != (id)[NSNull null]) {

    uniqueArray = [[NSSet setWithArray:bannerArrayFromDictionary] allObjects];
    animationArray = [uniqueArray copy];

    animationArray = [myArray shuffleArray:animationArray];

    NSMutableArray *images = [[NSMutableArray alloc] init];      

    NSString *imageName;

    for(int i=0; i<[animationArray count]; i++) {
        imageName = [NSString stringWithFormat:@"%@", [animationArray objectAtIndex:i]]; 
        [images addObject:[UIImage imageNamed:imageName]];
    }

    footer = [[UIView alloc] initWithFrame:CGRectMake(30,0,260,44)];

    bannerView *imgAdBar = [[bannerView alloc]initWithFrame:CGRectMake(footer.frame.origin.x,footer.frame.origin.y,footer.frame.size.width,footer.frame.size.height)];
    [imgAdBar saveBannerArray:animationArray];
    [imgAdBar setUserInteractionEnabled:YES];
    imgAdBar.animationImages = images;
    imgAdBar.animationDuration=[images count]*5;
    imgAdBar.animationRepeatCount=0;
    [imgAdBar startAnimating];

    [footer addSubview:imgAdBar];
    footer.backgroundColor = [UIColor clearColor];

  }
 return footer;
 }

以下是触摸事件的代码:

#import "bannerView.h"

@implementation bannerView

@synthesize bannerArray=_bannerArray;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"Touch Received");
}

- (void)saveBannerArray:(NSMutableArray *)localBannerArray {
    self.bannerArray=localBannerArray;
}

@end

我想我需要在touchesBegan中实现segue,但我需要知道如何确定收到触摸时显示的图像。有人可以帮忙吗?

提前感谢您的任何帮助!!

0 个答案:

没有答案