I have an activity view that I have added in AppDelegate class to tap bar:
[self.mainTabBar.view addSubview: spinner];
When there are connection problems it is visible in each view controller and is spinning. There is some button at certain view controller, makes to present some modal view controller. That modal view controller overlaps the spinner. How to make that spinner always be on top of all views or at least on top of that modal view controller? I tried to make such a thing in view controller that presents modal view controller:
[self presentModalViewController:selectionViewController animated:YES];
[self.view bringSubviewToFront:[self.tabBarController.view viewWithTag:15]];
Not works.
An app normally displays its content within a single window throughout its life. But there are situations where an extra window may be used to add content on top of everything else. Apple ensures
UIAlertView
always stays on top by adding it in a separate window.Show and hide your window by setting
window.hidden = Yes or No
as needed. This will always show yourcontentView
on top of everything else in the app.Add the view to the main window.
While phix23's answer is correct, here is a more complete example:
Remember to clean up after yourself when you don't need these any longer.
This code can be used from anywhere in your app, even a library :)
The modal controller is in a completely different layer, you cannot make any subview of the presenting controller to overlap it.
Use a
UIAlertView
with a spinner inside. The alerts are displayed in a layer which overlaps even modal controllers.