0

ユーザーが横向きから縦向きモードに回転したときに変更が表示されることなく、imageViewを設定しようとしました。

メソッドではwillAnimateRotationToInterfaceOrientation、画像を適切な画像に再設定します (横向きモードか縦向きモードかによって異なります)。

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];
}

ただし、ユーザーに変更が表示されない場所を作成する方法を判断するのに苦労しています。回転すると、大きな画像が小さな画像になることがわかります。私はこれをしたくありません。

移行をよりユーザーフレンドリーにする方法を知っている人はいますか? imageViewdidRotateFromInterfaceOrientationメソッドの設定も試してみましたが、改善されませんでした。

4

1 に答える 1

0

わかりました、これを行うためのより良い方法があったかどうかはわかりません。

私がしたこと:

メソッドではwillAnimateRotationToInterfaceOrientation、次のようにして tableFooterView を非表示にしました。

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;

}

次に、didRotateFromInterfaceOrientation方法で、私はすることにしました

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];

}

これにより、トランジションの見栄えが大幅に向上しました。

これが誰かに役立つことを願っています。誰かがより良いアイデアを持っている場合は、お気軽に質問に答えてください!

ありがとう!!!=)

于 2015-01-09T01:26:16.620 に答える