1

我正在从服务器检索 json 数据。json 数据包括一些图像和更多文本,最后但并非最不重要的 json 大小是不可预测的。

这是我检索json的方法:

-(void)viewWillAppear:(BOOL)animated {
    if (self.jsonUrl == nil) { 
    // This control is about MWPhotoBrowser. If user returned from photo browser do not retrieve data twice

        self.view.layer.shadowOpacity = 0.75f;
        self.view.layer.shadowRadius = 10.0f;
        self.view.layer.shadowColor = [UIColor blackColor].CGColor;

        if (![self.slidingViewController.underRightViewController isKindOfClass:[DetailContextViewController class]]) {
            self.slidingViewController.underRightViewController  = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailAbout"];
        }

        self.jsonUrl = [self.exampleAd getAdJSONLink];
        NSLog(@"%@", self.jsonUrl); // 

        [self backgroundTask]; // retrieving data
    } else {
        // User returned from MWPhotoBrowser so set the current height again/
        // This is not working somehow.
        [self.scrollView setContentSize:(CGSizeMake(320, currentHeight + 10))];
    }
}

我将所有这些数据添加到UIScrollView一个子视图中。假设这是B视图。所以滚动视图的高度是不确定的。我正在计算这样的高度和设置:

[self.scrollView setContentSize:(CGSizeMake(320, currentHeight + 10))];

这运作良好。这是我的问题:如果我从 B 回到 A 并再次从 A 到 B,则内容大小不起作用。滚动也不起作用,但我currentHeight的显示正确的值。即使是检索方法也不够用,实际上还有缓存之类的东西。

使用时也有同样的问题MWPhotoBrowser。当我使用当前模式控制器而不是再次返回 B 视图时,滚动不起作用。

我做错了什么,任何方法或线索都会很棒。

4

0 回答 0