りんご初心者です。私は現在、nickLockwood による iCarousel を勉強して試しています。iCarousel に画像を入れる予定です。だからここに私の .m と .h コードがあります:
// .m
@implementation ViewController
@synthesize images;
...
- (void)awakeFromNib
{
if (self) {
//set up carousel data
//wrap YES = infinite loop
wrap = YES;
self.images = [NSMutableArray arrayWithObjects:
@"apple.jpg",@"lemon.jpg",@"orange.jpg",@"melon.jpg",@"mango.jpg",nil];
}
}
- (UIView *)carousel:(iCarousel *)_carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
if (view == nil)
{
view = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[images objectAtIndex:index]]];
}
return view;
}
// .h
@interface ViewController : UIViewController <iCarouselDataSource, iCarouselDelegate>{
NSMutableArray *images;
...
}
@property (nonatomic,retain) NSMutableArray *images;
…
@end
30 枚の画像を追加する予定だったので、コードを保守しやすくしたいと考えています。私の問題は、NSBundle またはアプリケーション ディレクトリから画像を取得できるようにしたいことです。さまざまなコードを試しましたが、画像がカルーセルに表示されません。ご協力いただきありがとうございます。