UIViewController
我有一些代码在委托中显示两个。
根视图控制器.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
and 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
一个视图中的活动指示器。在我AuthenticationViewController
通过调用关闭登录按钮事件处理程序之一中的前一个对话框后,我以模态方式显示它dismissModalViewController
。在发送带有质询对象(以前缓存)的凭据后,我以模态方式显示 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];
}