1

他のビューをロードする前にログイン モーダル ウィンドウを最初に表示するコードを探していました。

ログインペン先を作成し、applicationDidFinishLaunching appdelegate で次のコードを使用します。

    [window addSubview:splitViewController.view];
    IntroView *introViewController=[[[IntroView alloc] initWithNibName:@"IntroView" bundle:nil]autorelease];
    [introViewController setModalPresentationStyle:UIModalPresentationFullScreen] ;
    [self.splitViewController presentModalViewController:introViewController animated:NO];
    [window makeKeyAndVisible];
...

これを実行すると、モーダル ウィンドウは表示されませんが、NSLog すると読み込まれます。なぜそれが表示されないのですか?

4

2 に答える 2

0

私のアプリは分割ビューで開始し、アクティブなセッション (コア データ エンティティで定義されている) がない場合は、モーダル ログイン ウィンドウを開きます。
viewDidAppear メソッドを最初の詳細ビュー コントローラーに追加します。
新しいログイン ビュー コントローラーへのモーダル セグエを作成します。
ログインビューでログインを行い、「[self disconnectModalViewControllerAnimated: YES];」でそれを閉じます。

- (void)viewDidAppear:(BOOL)animated<br>

{
[super viewDidAppear:animated];

    // Check if a existing session is open, if not the login screen will appear.
    // When user logs on an open session record is added to the table.  Closed on user logout.

    userProfile = [LogonSessionManager getCurrentPtuser:managedObjectContext];
    if(userProfile == nil){
    [self performSegueWithIdentifier:@"login" sender:self]; 
    } else {
        // We have a user - do user config display stuff
    }    
}
于 2012-03-26T12:19:12.303 に答える
0

@greentor: あなたの答えは完全には正しくありません。正しいモーダル セグエは、メインの SplitView からのものである必要があります。つまり、DetailViewController#viewDidAppear を呼び出す必要があります。

[self.splitViewController performSegueWithIdentifier:@"login" sender:self.splitViewController];
于 2012-05-07T12:36:51.690 に答える