【发布时间】:2011-07-14 20:16:28
【问题描述】:
我在关闭某个边缘情况下的模态视图控制器时遇到问题。当我检索要在 UIWebView 中显示的 PDF 时,我会显示模态视图。当我正在检索的文件非常小时,模式视图将尝试过早关闭。我在包含 UIWebView 的视图控制器中呈现模态视图。我在 UIWebView 的 didFinishLoad 委托方法中将其关闭。
我可以不为模态视图的初始演示设置动画……但这是否比我所做的更安全?这仍然有可能失败吗?如果有,你将如何改变它?我一直在查看文档,到目前为止我读过的任何内容都没有解决这种情况。
//
// This will download the file if not @ specific path, otherwise use local file.
// _myFileManager is a helper class and _myFileRecord is the backing data model
//
-(id)initWithNib... fileRecord:(MYFileRecord *)_myFileRecord
{
[_myFileManager cacheFileAsync:_myFileRecord delegate:self];
}
- (void)viewDidLoad
{
// doesn't seem to work, NO for animated does seem to work
[self.navigationController presentModalViewController:_splashController
animated:YES];
_splashController.messageLabel.text = @"Retrieving File...";
}
- (void)recordSaved:(MyFileRecord *)myFileRecord fileName:(NSString *)fileName
{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:fileName]];
[_webView loadRequest:request];
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
_splashController.messageLabel.text = @"Opening File...";
}
//
// This fails when a small file is already cached to disk and the time
// for the webView to finishLoad is faster than the splashView can present itself
//
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[self.navigationController dismissModalViewControllerAnimated:YES];
}
【问题讨论】:
标签: objective-c syntax foreach language-features