我有一些代码在委托中显示两个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
,它是视图中的活动指示符。在我通过名为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];
}
答案 0 :(得分:0)
我已经找到了解决方案,如果有人想要背靠背显示两个模态对话框,你应该在被解雇的控制器上将“animated”参数设置为“NO”。在下一个控制器显示“presentViewController”功能时,似乎没有完成动画转换。