トップ «前の日記(2012-06-24) 最新 次の日記(2012-06-26)» 編集

Cocoa練習帳

iOS/iPhone/iPad/watchOS/tvOS/MacOSX/Android プログラミング, Objective-C, Cocoa, Swiftなど

2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|07|08|09|10|11|12|
2019|01|02|03|04|05|06|07|08|09|10|11|12|
2020|01|02|03|04|05|06|07|08|09|10|11|12|
2021|01|02|03|04|05|06|07|08|09|10|11|12|
2022|01|02|03|04|05|06|07|08|09|10|11|12|
2023|01|02|03|04|05|06|07|08|09|10|11|12|
2024|01|02|

2012-06-25 [iOS]モーダルViewController(その3)

presentModalViewController:animated: の使用は推奨されなくなったようだ。

presentViewController:animated:completion: を使用するのだが、最後にBlockを指定するので期待したのだが、これはモーダル・ビュー表示後に実行する処理を記述する為で、独自にデリゲートやBlocksを用意する手間を省く為のものではないようだ。残念。


- (IBAction)modalPane:(id)sender
{
    ModalPaneViewController *viewController = [[ModalPaneViewController alloc] 
                                               initWithNibName:@"ModalPaneViewController"
                                               bundle:nil];
    [viewController setCompletionHandler:^(ModalPaneViewControllerResult result) {
        switch (result) {
            case ModalPaneViewControllerResultCancelled:
                [self performSelectorOnMainThread:@selector(didCancel:) withObject:nil waitUntilDone:NO];
                break;
            case ModalPaneViewControllerResultDone:
                [self performSelectorOnMainThread:@selector(didDone:) withObject:nil waitUntilDone:NO];
                break;
            default:
                break;
        }
        
        [self dismissModalViewControllerAnimated:YES];
    }];
    /* [self presentModalViewController:viewController animated:YES]; */
    [self presentViewController:viewController animated:YES completion:nil];
}

_ ソースコード

GitHubからどうぞ。
https://github.com/murakami/ModalPane - GitHub

トップ «前の日記(2012-06-24) 最新 次の日記(2012-06-26)» 編集