views:

76

answers:

0

Hi,

I have implement a nested UIScrollView based on apple developer website sample. It works fine until I turned on the orientation change. When it rotates, there will be some white color coming out during the rotation animation. And it will go away once the loading is completed. I have tried to set the backgroundcolor to black for both the big scrollview (with the contentSize equals to the number of photos * width of the photo), the individual scrollview.

Here are part of the code.

Thanks, Derek

- (void)loadView {
    // Step 1: make the outer paging scroll view
    CGRect pagingScrollViewFrame = [self frameForPagingScrollViewAtIndex:currentIndex];
    pagingScrollView = [[UIScrollView alloc] initWithFrame:pagingScrollViewFrame];
    pagingScrollView.pagingEnabled = YES;
    pagingScrollView.backgroundColor = [UIColor blackColor];
    pagingScrollView.showsVerticalScrollIndicator = NO;
    pagingScrollView.showsHorizontalScrollIndicator = NO;
    pagingScrollView.contentSize = CGSizeMake(pagingScrollViewFrame.size.width * [self imageCount],
                                              pagingScrollViewFrame.size.height);
    pagingScrollView.delegate = self;
    pagingScrollView.bounds = [self frameForPagingScrollViewAtIndex:currentIndex];
    self.view = pagingScrollView;

    // Step 2: prepare to tile content
    recycledPages = [[NSMutableSet alloc] init];
    visiblePages  = [[NSMutableSet alloc] init];
    [self tilePages];

}

- (void)switchView {
    [pagingScrollView release];
    CGRect pagingScrollViewFrame = [self frameForPagingScrollViewAtIndex:currentIndex]; 
    pagingScrollView = [[UIScrollView alloc] initWithFrame:pagingScrollViewFrame];
    pagingScrollView.pagingEnabled = YES;
    pagingScrollView.backgroundColor = [UIColor blackColor];
    pagingScrollView.showsVerticalScrollIndicator = NO;
    pagingScrollView.showsHorizontalScrollIndicator = NO;
    pagingScrollView.contentSize = CGSizeMake(pagingScrollViewFrame.size.width * [self imageCount],
                                              pagingScrollViewFrame.size.height);
    pagingScrollView.delegate = self;
    pagingScrollView.bounds = [self frameForPagingScrollViewAtIndex:currentIndex];
    self.view = pagingScrollView;

    [recycledPages release];
    [visiblePages release];
    recycledPages = [[NSMutableSet alloc] init];
    visiblePages  = [[NSMutableSet alloc] init];
    [self tilePages];

}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    if (!navBarHidden) {
        self.navigationController.navigationBar.alpha = 0;  
        [self setStatusBarHidden:YES animated:NO];
        navBarHidden = YES;
    }
    currentIndex = [self currentPage];
    UIImageView *iView = [self imageViewAtIndex:currentIndex];
    iView.contentMode = UIViewContentModeScaleAspectFit;
    iView.backgroundColor = [UIColor blackColor];
    ImageScrollView *page = [self scrollViewAtIndex:[self currentPage]];
    page.backgroundColor = [UIColor blackColor];
    self.view = iView;
}