开发者

How to determine when UIWebView modal view is removed?

开发者 https://www.devze.com 2023-02-04 14:40 出处:网络
I have a UITableView that when a cell is pressed a l开发者_C百科oading view is shown while a UIWebView loads its content (mp3 file).When the UIWebView starts to load, it pushes up its modal view.That

I have a UITableView that when a cell is pressed a l开发者_C百科oading view is shown while a UIWebView loads its content (mp3 file). When the UIWebView starts to load, it pushes up its modal view. That part works fine--the loading view is shown until the modal controller pushes up.

The problem is I can't find any kind of method to hit (web view delegate, viewDidAppear, etc) to determine when the modal view has closed so I can remove the loading view when returning to the tableview. The user still sees the loading view when the modal view closes.

Things I've tried:

1) Tried to use webViewDidFinishLoad, but it never gets called. (Doesn't get called on mp3's?)

2) Removing the loading view on webViewDidStartLoad--problem is the user looks at a white screen while it continues to load, which is kinda tacky and I'm trying to avoid it.

3) Putting the UIWebView in its own UIViewController and setting its view's alpha to 0. (Idea was to not see the white view and continue seeing the loading screen until the modal view shows up, then maybe catch a viewDidX method.)

Essentially, I want tableview -> loading screen -> webview modal view -> tableview (no loading screen present).

The only other thing I can think of is to create an invisible button ontop of the "done" button of the modal view and using that to determine when the webview closes.

Thoughts or suggestions?

Thanks,

John


Where and how do you dismiss the modal view with something like this:

[self dismissModalViewControllerAnimated:YES];

At this point you could, for example, send a notification that you would like the loading view to stop:

[[NSNotificationCenter defaultCenter] postNotificationName:@"STOP_LOADING_VIEW" object:nil];

The class that is showing the loading view would have to observe this notification:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stopLoadingView) name:@"STOP_LOADING_VIEW" object:nil];

And execute the method, that will deal with the loading view. There are many ways to achieve this behaviour, but you would have to show some code.


I think a better solution in this case would be to use the AVAudioPlayer since I just want audio, so that's what I'll probably end up doing.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号