0

したがって、元々画像を設定するために使用するコード(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]でクラッシュします。

4

2 に答える 2

0

更新から質問まで、まるでのように聞こえself.photoAlbumますnil。配列を割り当て、に割り当てたことを確認する必要がありますself.photoAlbum

これを行う:

self.photoAlbum = [[NSMutableArray alloc] init];

アレイに追加する前に。

于 2012-07-28T06:16:30.937 に答える
0

2つの画像のアニメーションが必要な場合は、それらの配列を作成してanimationImagesプロパティに設定してから、を呼び出すことができますstartAnimating

self.imageView.animationImages = self.photoAlbum;
[self.imageView startAnimating];

次に、animationDurationおよびanimationRepeatCountプロパティを設定することもできます。

于 2012-07-28T06:12:48.480 に答える