Вот и мы: вам нужна пользовательская ячейка для хранения массива фотографий.
Для отслеживания касания вам нужен пользовательский UIImageView.Для этого у вас есть 2 варианта: вы добавляете кнопку сверху или используете -touchesBegan (см. Ниже).
Теперь, когда вы нажимаете на картинку, она скажет своему родителю (ячейке), какая фотография была нажата.Ячейка будет пересылать информацию в RootViewController (класс с UITableView), также добавляя себя к информации.
Необходимые классы:
- RootViewController (здесь не реализовано)
- Ячейка
- CustomImageView
// Cell.h
import UIKit / UIKit.h
@class RootViewController;
@class CustomImageView;
@interface Cell : UITableViewCell
{
RootViewController *parent;
IBOutlet UIView *baseView; //I use this instead of content view; is more ..mutable
NSMutableArray *photosArray;
double cellHeight;
}
@property (nonatomic, assign) RootViewController *parent;
@property (nonatomic, retain) UIView *baseView;
@property (nonatomic, retain) NSMutableArray *photosArray;
@property double cellHeight;
(void) didClickPhoto: (CustomImageView*) image;
@end
//Cell.m
import "Cell.h"
@implementation Cell
@synthesize baseView, photosArray, cellHeight, parent;
- (void) didClickPhoto: (CustomImageView*) image
{
unsigned indexOfSelectedPhoto = [photosArray indexOfObject:image];
//this will allow you to reffere the pressed image;
[parent didClickPhotoAtIndex: indexOfSelectedPhoto inCell: self];
//you will inplement this function in RootViewController
}
@end
CustomImageView.h
#import <UIKit/UIKit.h>
#import "Cell.h"
@interface CustomImageView : UIImageView {
Cell *parent;
}
@property (nonatomic, assign) Cell *parent;
@end
CustomImageView.m
#import "CustomImageView.h"
@implementation CustomImageView
@synthesize parent;
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
[parent didClickPhoto:self];
}
@end
И это будет самый длинный ответ, который я когда-либо писал !!