ALAssets ライブラリを使用して画像ピッカーを構築しようとしていますが、アルバムを含むテーブル ビューがありますが、アルバムをクリックして写真を表示すると、カスタム UITableViewCells で構成される動的な UITableViewController でプロパティを割り当てることができません。カスタム AlbumContentTableViewCells...
cell.rowNumber と indexPath.row は両方とも NSIntegers ですが、認識されないセレクターについて不平を言っています...
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
AlbumContentsTableViewCell *cell = [[AlbumContentsTableViewCell alloc] init];
cell = (AlbumContentsTableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"Photo"];
cell.rowNumber = indexPath.row;
cell.selectionDelegate = self;
// Configure the cell...
NSUInteger firstPhotoInCell = indexPath.row * 4;
NSUInteger lastPhotoInCell = firstPhotoInCell + 4;
if (assets.count <= firstPhotoInCell) {
NSLog(@"We are out of range, asking to start with photo %d but we only have %d", firstPhotoInCell, assets.count);
return nil;
}
NSUInteger currentPhotoIndex = 0;
NSUInteger lastPhotoIndex = MIN(lastPhotoInCell, assets.count);
for ( ; firstPhotoInCell + currentPhotoIndex < lastPhotoIndex ; currentPhotoIndex++) {
ALAsset *asset = [assets objectAtIndex:firstPhotoInCell + currentPhotoIndex];
CGImageRef thumbnailImageRef = [asset thumbnail];
UIImage *thumbnail = [UIImage imageWithCGImage:thumbnailImageRef];
switch (currentPhotoIndex) {
case 0:
[cell photo1].image = thumbnail;
break;
case 1:
[cell photo2].image = thumbnail;
break;
case 2:
[cell photo3].image = thumbnail;
break;
case 3:
[cell photo4].image = thumbnail;
break;
default:
break;
}
}
return cell;
}
このカスタム UITableCell に「rowNumber」プロパティを割り当てようとすると、次のエラーが発生します。
'NSInvalidArgumentException'、理由: '-[UITableViewCell setRowNumber:]: 認識されないセレクターがインスタンス 0x1e2a43a0 に送信されました'
AlbumContentsTableViewCell.h
#import <UIKit/UIKit.h>
#import "ThumbnailImageView.h"
@class AlbumContentsTableViewCell;
@protocol AlbumContentsTableViewCellSelectionDelegate <NSObject>
- (void)albumContentsTableViewCell:(AlbumContentsTableViewCell *)cell selectedPhotoAtIndex:(NSUInteger)index;
@end
@interface AlbumContentsTableViewCell : UITableViewCell <ThumbnailImageViewSelectionDelegate> {
IBOutlet ThumbnailImageView *photo1;
IBOutlet ThumbnailImageView *photo2;
IBOutlet ThumbnailImageView *photo3;
IBOutlet ThumbnailImageView *photo4;
NSInteger rowNumber;
//id <AlbumContentsTableViewCellSelectionDelegate> selectionDelegate;
}
@property (nonatomic) NSInteger rowNumber;
@property (nonatomic, weak) id<AlbumContentsTableViewCellSelectionDelegate> selectionDelegate;
- (UIImageView *)photo1;
- (UIImageView *)photo2;
- (UIImageView *)photo3;
- (UIImageView *)photo4;
- (void)clearSelection;
@end
AlbumContentsTableViewCell.m
#import "AlbumContentsTableViewCell.h"
#import "ThumbnailImageView.h"
@implementation AlbumContentsTableViewCell
@synthesize rowNumber;
@synthesize selectionDelegate;
#import <UIKit/UIKit.h>
@class ThumbnailImageView;
@protocol ThumbnailImageViewSelectionDelegate <NSObject>
- (void)thumbnailImageViewWasSelected:(ThumbnailImageView *)thumbnailImageView;
@end
@interface ThumbnailImageView : UIImageView {
UIImageView *highlightView;
id <ThumbnailImageViewSelectionDelegate> delegate;
}
@property(nonatomic, assign) id<ThumbnailImageViewSelectionDelegate> delegate;
- (void)clearSelection;
@end