Professional Documents
Culture Documents
// AssetCell.m
//
// Created by ELC on 2/15/11.
// Copyright 2011 ELC Technologies. All rights reserved.
//
#import "ELCAssetCell.h"
#import "ELCAsset.h"
#import "ELCConsole.h"
#import "ELCOverlayImageView.h"
@interface ELCAssetCell ()
@end
@implementation ELCAssetCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString
*)reuseIdentifier
{
self = [super initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:reuseIdentifier];
if (self) {
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(cellTapped:)];
[self addGestureRecognizer:tapRecognizer];
self.alignmentLeft = YES;
}
return self;
}
- (void)setAssets:(NSArray *)assets
{
self.rowAssets = assets;
for (UIImageView *view in _imageViewArray) {
[view removeFromSuperview];
}
for (ELCOverlayImageView *view in _overlayViewArray) {
[view removeFromSuperview];
}
//set up a pointer here so we don't keep calling [UIImage imageNamed:] if
creating overlays
UIImage *overlayImage = nil;
for (int i = 0; i < [_rowAssets count]; ++i) {
ELCAsset *asset = [_rowAssets objectAtIndex:i];
- (void)cellTapped:(UITapGestureRecognizer *)tapRecognizer
{
CGPoint point = [tapRecognizer locationInView:self];
int c = (int32_t)self.rowAssets.count;
CGFloat totalWidth = c * 75 + (c - 1) * 4;
CGFloat startX;
if (self.alignmentLeft) {
startX = 4;
}else {
startX = (self.bounds.size.width - totalWidth) / 2;
}
- (void)layoutSubviews
{
int c = (int32_t)self.rowAssets.count;
CGFloat totalWidth = c * 75 + (c - 1) * 4;
CGFloat startX;
if (self.alignmentLeft) {
startX = 4;
}else {
startX = (self.bounds.size.width - totalWidth) / 2;
}
@end