-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using 'presentPointingAtBarButtonItem:' from a UINavigationBar on a ViewController in a Tabbed app, the poptip is visible on all tabs #137
Comments
@kleinlieu What do you think of my analysis? |
I've got the same issue, where I have pop-up ViewControllers - tooltips for the NavigationBar in the background view still shown on top of everything. |
@NikolayEntin It seems this project isn't under active development anymore, as the last commit is from 7 months ago. |
@funnel20, thank you, I've actually reverted the code to previous state, instead of:
I use old one:
But I'm still wondering for motivation of the change - it did work in the past, why change to the 'window' as container for the pop-up view? What side-effects one can expect with the old code? |
@funnel20 I recognized that my code was not enough (I did it via class inheritance), as for some reason those tooltips were not dismissable on click afterwards. I applied your code to the original file and it seem to work like a charm! |
Situation
The app is build as a Tabbed App, so it has an UITabBarController as root view controller.
Each Tab has it's own view controller.
On the 4th tab we have an UITableViewController with an UINavigationBar with left and right UIBarButtonItems.
We've created an IBOutlet
infoButton
and present the pop tip by callingpresentPointingAtBarButtonItem:animated:
:The pop tip is correctly shown:
However, when selecting another tab via the Tab Bar, the pop tip is still visible:
Analysis
Method
presentPointingAtBarButtonItem:animated:
determines the container view of the UIBarButtonItem and callspresentPointingAtView:inView:animated:
with it.The problem is it uses:
Where the app window is returned. This is the reason why the pop tip is visible on all tabs in a Tabbed App.
Solution
The proper container view is the superview of the parent view of the UIBarButtonItem.
The (public) parent view of an UIBarButtonItem is one of:
So the first step is to search upwards in the view hierarchy to determine whether the Bar Button is located in a Navigation Bar, Tool Bar or Tab Bar.
When a Navigation Bar, Tool Bar or Tab Bar is found, return it's superview and abort the search.
When no Navigation Bar, Tool Bar or Tab Bar is found, the default strategy is to use the app window (existing situation).
Here is my updated code for this method:
Validation
This has been tested and now the pop tip is only shown on the view controller of the specific tab, which is the intended behaviour.
An added benefit is that this also works when presenting the pop tip from a Tab Bar button (this can be added to the ReadMe).
In this case the intended behaviour is that the pop tip is always visible, no matter which tab is selected.
Because the new code uses the superview of the UITabBar, this is the case.
In this example the pop tip is always presented from the 4th tab, even if it's not the selected tab:
The text was updated successfully, but these errors were encountered: