したがって、元々画像を設定するために使用するコード(BlueToothを介して別のiOSデバイスからデータを受信します)
UIImage *receivedImage = [UIImage imageWithData:data];
if(receivedImage != nil)
{
NSLog(@"Image received is not nil.");
}
self.imageView.image = receivedImage;
UIImageView *iv = [[UIImageView alloc] initWithImage:receivedImage];
[self.view addSubview:iv];
[self.photoAlbum addObject:receivedImage];
画像を設定することで魅力のように機能します。
ただし、NSMutableArrayプロパティ「album」に追加しようとしても、画像は変更されません。
-(void)stereoscopicIterationA {
self.imageView.image = nil;
self.imageView.image = [self.photoAlbum objectAtIndex:1];
NSTimer *theTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(stereoscopicIterationB) userInfo:nil repeats:NO];
NSLog(@"Image 1");
}
-(void)stereoscopicIterationB {
self.imageView.image = nil;
self.imageView.image = [self.photoAlbum objectAtIndex:0];
NSTimer *theTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(stereoscopicIterationA) userInfo:nil repeats:NO];
NSLog(@"Image 0");
}
-(void)openAlbum:(id)sender
{
if([self.photoAlbum objectAtIndex:0] != nil && [self.photoAlbum objectAtIndex:1] == nil)
{
self.imageView.image = [self.photoAlbum objectAtIndex:0];
[self dismissModalViewControllerAnimated:NO];
}
else if([self.photoAlbum objectAtIndex:0] !=nil && [self.photoAlbum objectAtIndex:1] !=nil ){
//Set up NSTimer to swap self.imageView.image back and forth between 0 and 1 of photoAlbum.
NSLog(@"Timer set up");
NSTimer *theTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(stereoscopicIterationA) userInfo:nil repeats:YES];
}
何か案は?
具体的には、アルバムNSMutableArrayに画像がまったく追加/保持されていないようです。プログラムが範囲外エラー[0..0]でクラッシュします。