我有一个自定义UIViewController
显示与presentModalViewController
函数在http基本认证委托获取用户名和密码。我想等到用户点击屏幕上显示的模式视图控制器上的登录按钮。我怎样才能做到这一点?我是iOS新手,任何意见或链接将不胜感激。如何等待,直到模式对话框返回结果在ios
编辑:这里是内NSURLConnectionDelegate
-(void) connection(NSURLConnection*)connection willSendRequestForAuthenticationChallenge(NSURLAuthenticationChallenge*)challenge
{
CustomAuthViewController *authView = [CustomAuthViewController alloc] initWithNibName"@"CustomAuthViewController" bundle:[NSBundle mainBundle]];
[parentcontroller presentModalViewController:authView animated:YES];
//
// I want to wait here somehow till the user enters the username/password
//
[[challenge sender] userCredentials:credentials forAuthenticationChallenge:challenge];
}
亲切的问候一个示例代码。
编辑:解决方案:不必立即发送willSendRequestForAuthenticationChallenge委托函数中的凭据。我可以随时发送它,但是很奇怪。
一旦用户点击按钮,你可以关闭modalViewController,是否你想要什么? – Peres
不幸的是没有!我正在显示一个自定义的UIViewController来收集用户/密码在willSendRequestForAuthenticationChallenge函数中。现在,我必须等到用户输入用户名/密码并单击登录按钮视图...否则我将无法在presentModalViewController后的下一行发送userCredentials:forAuthenticationChallenge :( – CodeWeed