0

IOS 6 より前は、以下のコードを使用して、カスタマイズされたサイズのモーダル ビューを表示しました。

- (void) showModalViewWithController:(GUIViewController*) _viewController {
    [UIView beginAnimations:@"" context:nil];
    [self presentModalViewController:_viewController animated:YES];
    _viewController.view.superview.autoresizingMask = UIViewAutoresizingFlexibleHeight;
    _viewController.view.superview.frame = CGRectMake(
        _viewController.view.superview.frame.origin.x,
        _viewController.view.superview.frame.origin.y,
        700.0f,
        self.view.frame.size.height - 80.f);
    _viewController.view.superview.center = self.view.center;

    [UIView commitAnimations];
}

今、私は関数を変更する必要があります

- (void)presentModalViewController: (UIViewController *)viewControllerToPresent animated:(BOOL)flag

- (void)presentViewController: (UIViewController *)viewControllerToPresent animated: (BOOL)flag completion: (void (^)(void))completion

残念ながら、次のような変更後、サイズの調整はうまく機能しません。

- (void) showModalViewWithController:(GUIViewController*) _viewController {
    [self presentViewController:_viewController animated:YES completion:^(){
        [UIView beginAnimations:@"" context:nil];
        _viewController.view.superview.autoresizingMask = UIViewAutoresizingFlexibleHeight;
        _viewController.view.superview.frame = CGRectMake(
            _viewController.view.superview.frame.origin.x,
            _viewController.view.superview.frame.origin.y,
            700.0f,
            self.view.frame.size.height - 80.f);
        _viewController.view.superview.center = self.view.center;
        [UIView commitAnimations];
    }];
}

フレーム操作の前にモーダル ビューが表示され、完了ブロックの呼び出し後にジャンプするためです。

それに対処する方法は?

前もって感謝します、

ミハウ

4

2 に答える 2

0

完了ブロックのアニメーションがジャンプする理由が正確にはわかりません。私はこの[UIView beginAnimations:context:]メソッドを使用したことがありません。私は通常、のようなブロックベースのアニメーションメソッドを呼び出します[UIView animateWithDuration:animations:completion:]。これは、iOS4以降ではbeginAnimationsメソッドの使用が推奨されていないためです。

代わりにブロックベースの方法を使用するようにアニメーションを変更してみます。アニメーションをコミットした後、奇妙なスレッドの問題が発生する可能性があります。

事前にサイズを変更するのではなく、表示にビューのサイズを変更しているのはかなり興味深いと思います。

于 2012-10-27T02:05:18.427 に答える