0

I've been trying to set an imageView without the the user seeing it change when they rotate from landscape to portrait mode.

In willAnimateRotationToInterfaceOrientation method, I re-set the image to the appropriate image (depending on if it's in landscape mode or portrait mode:

if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
    NSLog(@"Going to Portrait Mode.");

    UIImage *footerImage = [UIImage imageNamed:@"SchoolImageLandscape.png"];
    UIImageView *fView = [[UIImageView alloc] initWithImage:footerImage];
    [self.tableView setTableFooterView:fView];



} else if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
    NSLog(@"Portrait Mode");
    UIImage *footerImage = [UIImage imageNamed:@"SchoolImage.png"];
    UIImageView *fView = [[UIImageView alloc] initWithImage:footerImage];
    [self.tableView setTableFooterView:fView];
}

However, I'm having some trouble determining how to make it where the user doesn't see the change. Meaning when it rotates you see the larger image become a smaller image. I don't want this.

Does anyone know how to make the transition more user-friendly? I've also tried setting the imageView didRotateFromInterfaceOrientation method and it wasn't any better.

jww
  • 97,681
  • 90
  • 411
  • 885
Sandy D.
  • 3,166
  • 1
  • 20
  • 31

1 Answers1

0

Okay, I don't know if there was a better way to do this.

What I did:

In the willAnimateRotationToInterfaceOrientation method, I hid the tableFooterView by doing this:

if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
    // hide the footer image so that the user doesn't see
    // the image go from large image (landscape) to a smaller image
    self.tableView.tableFooterView.hidden = YES;

}

Then in, didRotateFromInterfaceOrientation method, I decided to

if (UIInterfaceOrientationIsLandscape(fromInterfaceOrientation)) {
    NSLog(@"Going to Portrait Mode.");

    UIImage *footerImage = [UIImage imageNamed:@"SchoolImage.png"];
    UIImageView *fView = [[UIImageView alloc] initWithImage:footerImage];

    [self.tableView setTableFooterView:fView];

    // unhide the footer
    self.tableView.tableFooterView.hidden = NO;

    // set the alpha to 0 so you can't see it immediately
    fView.alpha = 0.0f;

    // Fade in the image
    [UIView transitionWithView:fView
                      duration:1.0f
                       options:0
                    animations:^{
                        fView.alpha = 1.0f;
                    } completion:nil];

}

This made the transitioning look a LOT better.

Hope this helps someone. If anyone has a better idea, please feel free to answer the question too!

Thanks!!! =)

Sandy D.
  • 3,166
  • 1
  • 20
  • 31