2012-05-07 14 views
0

我有一些代碼在代理中顯示兩個UIViewController以模態方式在刪除函數中顯示查看控制器

RootViewController.m

request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"***some https url here ***"]]; 
// custom implementation of NSURLConnectionDelegate 
dataman = [[DataManager alloc] initWithParentcontroller:self]; 
mainConn = [[NSURLConnection alloc] initWithRequest:request delegate:dataman]; 

在AuthenticationViewController.h

@protocol ShowAuthenticationWindowDelegate <NSObject> 
@required 
- (void) onFinishedEnteringCredentials:(NSURLCredential*)credentials; 
- (void) onCancelAuthentication; 
@end 

在AuthenticationViewController.m

- (IBAction) onClickLogin:(id)sender; 
{ 
    .... 
    // authDelegate => id <ShowAuthenticationWindowDelegate> 
    [authDelegate onFinishedEnteringCredentials:credentials]; 
    [self dismissModalViewControllerAnimated:YES]; 
    .... 
} 

在DataManger.h(DataManager類)實施NSURLConnectionDelegateShowAuthenticationWindowDelegate

在Datamanager.m中 在didReceiveAuthenticationChallenge委託函數中,我將AuthentiationViewController顯示爲模式對話框以收集用戶名/密碼。

-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge 
{ 
    AuthenticationViewController *authview = [[AuthenticationViewController alloc] initWithNibName:@"AuthenticationViewController" bundle:[NSBundle mainBundle]]; 
    authview.modalPresentationStyle = UIModalPresentationFullScreen; 
    authview.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
    authview.credentialsDelegate = self; 
    [rootController presentModalViewController:authview animated:YES]; 
} 

這裏我顯示一個UIViewController這是一個視圖中的活動指標。我通過調用dismissModalViewController在登錄按鈕事件處理程序之一中解除先前的AuthenticationViewController對話框後,以模態形式顯示它。在發送具有挑戰對象(以前緩存)的證書之後,我以模態方式顯示ActivityViewController,但是不會顯示,無論我做什麼。我試圖顯示一個UIAlertView哪些工作,但我的activityviewcontroller沒有顯示。我檢查了參數和對象都是有效的。即使代表佈線!所有的代碼都被調用,但對話框沒有顯示。

可能是我缺少的東西?

- (void) onFinishedEnteringCredentials:(NSURLCredential*)credentials; 
{ 

    [[authChallenge sender] useCredential:credentials forAuthenticationChallenge:authChallenge]; 
    // create an activity modal dialog 
    if (activityController == nil) { 
     activityController = [[ActivityViewController alloc] initWithNibName:@"ActivityViewController" bundle:[NSBundle mainBundle]]; 
     activityController.modalPresentationStyle = UIModalPresentationFullScreen; 
     activityController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
    } 
    [rootController presentModalViewController:activityController animated:YES]; 
} 

回答

0

我必須弄明白的解決方案,如果有人想顯示兩個模式對話框背靠背,你應該設置「動畫」參數是被解僱控制器上「NO」。看起來下一個控制器顯示「presentViewController」函數時,動畫轉換沒有完成。

相關問題