1

情報を表示するためのラベルが付いたサブビューを含む基本的なストーリーボードがあります。このビューは画面外に隠され、ユーザーが音楽を再生/一時停止すると上下にポップアップします。このビューは、画面の下部から始まり、それに応じてアニメーション化されます。

画面上の別のボタンを押すと、モーダル ウィンドウが開きます。このモーダルを開くと、ラベル付きのサブビューは画面外の初期状態に戻ります。メインのView Controllerに通知センターがあり、このモーダルが閉じられたときに正常に検出されますが、音楽が再生されている場合は適切な関数を呼び出してサブビューを再度表示します。ただし、アニメーションなしで値を直接設定しても、何らかの理由でビューがアニメーション化しません。それでも、一時停止/再生を押すと、本来のように再び表示されます。

ビューが再描画の準備ができた後にのみアニメーションが呼び出されるように、適切なコールバックを使用する必要があると思いますか?モーダルを開くメソッドと、モーダルが閉じられたときに呼び出されるメソッドを以下に示します。

// open modal from a .xib
- (IBAction)openModal:(id)sender {
    ifmSettingsViewController* svc = [[ifmSettingsViewController alloc] initWithNibName:@"Settings" bundle:nil];
    [svc setModalPresentationStyle:UIModalPresentationFullScreen];
    [svc setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];

    [[NSNotificationCenter defaultCenter] addObserver:self
        selector:@selector(didDismissSecondViewController)
        name:@"SecondViewControllerDismissed"
        object:nil];
    [self presentViewController:svc animated:TRUE completion:nil];
}
// called when modal window dismissed
-(void)didDismissSecondViewController {
    NSLog(@"Dismissed SecondViewController");
    [self viewDidAppear:TRUE];
    // calculate appropriate distance from screen bottom
    float yer = [[UIScreen mainScreen] bounds].size.height - 101.0;
    self.infoview.center = yer;
}

モーダル内では、次のように閉じます。

- (IBAction)backHit:(id)sender {
    [self dismissViewControllerAnimated:TRUE completion:^{
        [[NSNotificationCenter defaultCenter] postNotificationName:@"SecondViewControllerDismissed"
            object:nil
            userInfo:nil
        ];
        return;
    }];
}
4

0 に答える 0