ファイルから配列に画像をロードするのに問題があります。私はここで見つけた質問を組み合わせて使用しましたが、アイデアがありません。...私はobjective-cに不慣れで、残りはさびています。
私のviewDidLoadは単にshowPicsメソッドを呼び出します。テストのために、_imgViewは配列の位置1にある画像を表示するだけです。
画像の表示方法にも問題がある可能性があります。ストーリーボードにViewControllerと1つのImageView(タイトル:imgView)があります。
これが私のshowPicsメソッドです:
-(void)showPics
{
NSArray *PhotoArray = [[NSBundle mainBundle] pathsForResourcesOfType:@"jpg" inDirectory:@"Otter_Images"];
NSMutableArray *imgQueue = [[NSMutableArray alloc] initWithCapacity:PhotoArray.count];
for (NSString* path in PhotoArray)
{
[imgQueue addObject:[UIImage imageWithContentsOfFile:path]];
}
UIImage *currentPic = _imgView.image;
int i = -1;
if (currentPic != nil && [PhotoArray containsObject:currentPic]) {
i = [PhotoArray indexOfObject:currentPic];
}
i++;
if(i < PhotoArray.count)
_imgView.image= [PhotoArray objectAtIndex:1];
}
これが私のviewDidLoadです:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self showPics];
}
これが私のViewController.hです
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIImageView *imgView;
@end
他にご不明な点がございましたら、お気軽にお問い合わせください。