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

You need to redesign your code.

If you want same code to be run from viewDidLoad and from other method, pull those codes out of viewDidLoad and put it in a method and call this method from viewDidLoad and from your method.

As calling viewDidLoad explicitly is not good.

于 2013-03-18T17:50:10.087 回答