我有一些代碼在代理中顯示兩個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類)實施NSURLConnectionDelegate
和ShowAuthenticationWindowDelegate
。
在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];
}