Giter Club home page Giter Club logo

Comments (4)

jallen avatar jallen commented on August 29, 2024

I've had the same problem.
My question is do we need a topView?
Why not just use the parentView? (What am I missing?)

from popoverview.

ocrickard avatar ocrickard commented on August 29, 2024

In response to @jallen, I built this component so I could present a popover from a UIView subclass with clipping enabled. I'm now tempted to just add a new UIWindow to the top of the window stack.

As for checking for the hidden state of topView, I think this solution reveals an underlying problem: I had assumed that the topView would be adequate, but it is clearly not. We could continue looking for hidden or clipped subviews, but what if their layer's zPosition is set below others such that the popover is not visible?

I'll think on this, and look at more general solutions.

from popoverview.

devios1 avatar devios1 commented on August 29, 2024

I have to agree with @jallen. Using the immediate superview (or some customizable ancestor) makes a lot more sense. I am using popovers inside a scrollView that I am using to display text field validation warnings. In this case I naturally want the popovers to scroll with the text fields, but by using the topView (or a new UIWindow as you suggest), the popover is outside of the scrollView and remains static on the screen while the underlying view is scrolled, forcing me to hide the validation messages if/when the scrollView is scrolled.

Instead, to solve your problem of the popover being attached to a view with clipping enabled, would it not make more sense for the target view to be overridable? This is a pattern I am employing in my app: if you don't specify the target view, it defaults to self.superview. This lets you specify any parent view (or even a completely different window if so desired) without losing the ability for the popover to be directly attached to the immediate superview and thus contained inside any scrollViews, etc.

I made the following simple changes and things seem to be working great. I probably broke something else, but for my use this is working perfectly (the popover views now scroll appropriately with the views they are attached to):

PopoverView.m
Line 483: topView = view;
Line 525: topViewBounds = topView.frame;

That's all it took, and it works great now. You can still specify what view you want the popover to appear in, and that simply becomes the topView now. No need to actually attach the view to the top-most view.

from popoverview.

wasauce avatar wasauce commented on August 29, 2024

@devios1337 If you have a pull request we can investigate if there are conflicts and potentially merge

from popoverview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.