在下一个模式视图出现之前,我正在使用UIAlertView
输入用户名和密码凭据,这使他可以访问他帐户中的文件。
但是,当我调试时,我知道模态视图的“ViewDidLoad”方法在 alertView 出现之前被调用,因此程序崩溃,因为视图无法获取用户名和密码。
这是代码
-(IBAction) openShareFile:(id)sender
{
if (!self.shareFileBrowser) {
self.shareFileBrowser=[[ShareFileBrowserViewController alloc] initWithNibName:@"ShareFileBrowserViewController" bundle:nil];
self.alertView = [[UIAlertView alloc] initWithTitle:@"Verify your Credentials" message:@"Enter Username & Password" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
self.alertView.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
[self.alertView show];
self.shareFileBrowser.domain=@"fidomoose";
self.shareFileBrowser.delegate=self;
self.shareFileBrowser.title=@"ShareFile Browser";
self.navController= [[UINavigationController alloc] initWithRootViewController:self.shareFileBrowser];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
self.popController = [[UIPopoverController alloc] initWithContentViewController:self.navController];
}
}
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
if ([self.popController isPopoverVisible]) {
[self.popController dismissPopoverAnimated:YES];
} else {
[self.popController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}
else {
[self presentModalViewController:self.navController animated:YES];
}
}