0

私の最初のクラスはゲラクラスで、ギャラリークラスから変数とオブジェクトを画像表示クラスに渡します。画像表示クラスには次の画像ボタンがあり、そのボタンを押すと、画像表示クラスに存在するすべての画像が表示されます変える必要がある。

       MixViewController *mixVC = [[MixViewController alloc] init];
    mixVC.readOnlyMode = YES;
    mixVC.location = location;

    NSArray *tree = location.gallerySerialised;
    NSDictionary *galleryEntryTree = [tree objectAtIndex:tappedCoverIndex];
    NSArray *sliderStates = [galleryEntryTree objectForKey:@"state"];
    mixVC.infotext=[galleryEntryTree objectForKey:@"description"];
    mixVC.authortext=[galleryEntryTree objectForKey:@"author"];
    mixVC.tappedIndex=tappedCoverIndex;

    mixVC.initialSliderStates = [NSArray arrayWithObjects:
                                 [NSNumber numberWithInt:[[sliderStates objectAtIndex:0] intValue]],
                                 [NSNumber numberWithInt:[[sliderStates objectAtIndex:1] intValue]],
                                 [NSNumber numberWithInt:[[sliderStates objectAtIndex:2] intValue]],
                                 [NSNumber numberWithInt:[[sliderStates objectAtIndex:3] intValue]],
                                 [NSNumber numberWithInt:[[sliderStates objectAtIndex:4] intValue]],
                                 [NSNumber numberWithInt:[[sliderStates objectAtIndex:5] intValue]],
                                 nil];


    mixVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self.parentViewController presentModalViewController:mixVC animated:YES];

これは mixviewcontroller を呼び出す私のコードです。次のボタンを押すと、 Sliderstates の値を変更し、ビューをリロードして、スライダーとギャラリーのインデックスに従って新しい画像を表示します。

ユーザーがnextGalleryview関数を呼び出すよりも次をクリックすると、そのクラスの混合画像クラスになり、画像を変更したいのですが、機能しません

同じ値を渡して self view-did-load を呼び出すこのコードを書きますが、何も変更されません。

どんな助けでも大歓迎ですありがとう

   -(void)nextGalleryView
      {
     NSLog(@"tap index is %i",tappedIndex);
        [ScrollView removeFromSuperview];
    self.readOnlyMode = YES;
    self.location = location;
    NSArray *tree = location.gallerySerialised;
    NSDictionary *galleryEntryTree = [tree objectAtIndex:tappedIndex];
    NSArray *sliderStates = [galleryEntryTree objectForKey:@"state"];
    self.infotext=[galleryEntryTree objectForKey:@"description"];
    self.authortext=[galleryEntryTree objectForKey:@"author"];
    self.tappedIndex=tappedIndex;

    self.initialSliderStates = [NSArray arrayWithObjects:
                                 [NSNumber numberWithInt:[[sliderStates objectAtIndex:0] intValue]],
                                 [NSNumber numberWithInt:[[sliderStates objectAtIndex:1] intValue]],
                                 [NSNumber numberWithInt:[[sliderStates objectAtIndex:2] intValue]],
                                 [NSNumber numberWithInt:[[sliderStates objectAtIndex:3] intValue]],
                                 [NSNumber numberWithInt:[[sliderStates objectAtIndex:4] intValue]],
                                 [NSNumber numberWithInt:[[sliderStates objectAtIndex:5] intValue]],
                                nil];
    [self viewDidLoad];
    }
4

1 に答える 1

3

コードを再設計する必要があります。

viewDidLoad と他のメソッドから同じコードを実行する場合は、それらのコードを viewDidLoad から取り出してメソッドに入れ、viewDidLoad とメソッドからこのメソッドを呼び出します。

viewDidLoad を明示的に呼び出すのは良くありません。

于 2013-03-18T17:50:10.087 に答える