特定のエッジケースでモーダルビューコントローラを解除する際に問題が発生しました。私はUIWebViewで表示するPDFを取得しているときにモーダルビューを表示します。取得しているファイルが非常に小さい場合、モーダルビューはあまりにも早く終了しようとします。 UIWebViewを含むビューコントローラにモーダルビューを表示します。私はそれをUIWebViewのdidFinishLoadデリゲートメソッドで却下します。objective-c modalViewController too fast
私は、モーダルビューの最初のプレゼンテーションをアニメーションではないと元気です...しかし、私は何をやっていたよりも、それ以上に安全ということでしょうか?これはまだ失敗する可能性がありますか?もしそうなら、あなたはそれをどのように変更しますか?私はドキュメントを見てきましたが、これまでに読んだことは何もこの状況を強調していません。
//
// 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];
}
これはうまくいきましたが、私はただ1つのbool readyToDismissを使用し、shouldDismissをそれに置き換えます。あなたはそれに間違ったことを見ますか? –
いいえpb、これもOKです(さらに簡単です)!私は答えの可読性のために2つのBOOLを使用しましたが、あなたは正しいです。両方の場合にのみ1つのBOOLを使用します(この場合、Webviewより前に終了したアニメーションまたはその反対)。 – AliSoftware