Giter Club home page Giter Club logo

Comments (6)

ocrickard avatar ocrickard commented on July 25, 2024

Interesting. So from this, it would appear that the PopoverView is being created (initWithFrame) with an invalid frame rect, as you suggest. I really can't imagine why this would happen, since I call initWithFrame with a frame of CGRectZero which is defined as the rect (0,0,0,0), not (NaN, NaN, 0, 0), unless your runtime has this definition overridden somewhere?

The second part that is unusual to me is the fact that the topViewBounds is CGRectZero here. This would suggest to me that your window stack is not setup as I had assumed. If you wouldn't mind, in the - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withContentView:(UIView *)cView, could you check for the existence and state of topView? If it was unable to find a valid subview of either the UIApplication's keyWindow, or the top of the window stack, then you may have a bad topView var. If this is the case, try replacing the line

topView = [[window subviews] objectAtIndex:0];

with:

topView = window;

Since UIWindow is a subclass of UIView, you can actually just add the popover directly to the window, which will put it at the top of the subview stack.

It would appear that the view state is very unusual in your case. I can only think of two reasons that this may occur: 1. You are calling the PopoverView before the application's window stack has been fully initialized. 2. You are performing this method from a background thread that is unsafely accessing vars on the main thread.

These are just guesses, but if I can get more info on how you're using this, or if you could replicate the problem in the demo project, then I can try to add a workaround to the code base. If the problem is arising from background usage, I would suggest you wrap your PopoverView code in a dispatch_async on the main thread.

from popoverview.

Wirsing84 avatar Wirsing84 commented on July 25, 2024

Thank you for your elaborate answer!

I checked the topview frame - after [[window subviews] objectAtIndex:0]; it remains a CGRectZero (0, 0, 0, 0) (I have not changed its implementation)

With topView = window; it works as it should.

I'm calling from a "normal" button via an IBAction (long after the window stack is set up). Also I am positively doing it in the Main Thread, I'm calling it from a method directly in my main View Controller.

However, I just found out what the problem is:
I enumerated and logged the descriptions of the objects in [window subviews] and it returns this:

UITextView: 0xc970e00; frame = (0 0; 0 0); text = ''; clipsToBounds = YES; gestureRecognizers = <NSArray: 0xb97ce50>; layer = CALayer: 0xb97c890; contentOffset: {0, 0}

UILayoutContainerView: 0xaabed40; frame = (0 0; 320 480); autoresize = W+H; layer = CALayer: 0xaabee00

DCFrameView: 0x12666230; frame = (0 0; 320 480); alpha = 0; opaque = NO; layer = CALayer: 0x126662c0


What is this, you say?
Well, UITextView (at index 0) with frame 0 0 0 0 obviously creates the problem. And DCFrameView gives away what is happening. I am using DCIntrospect - https://github.com/domesticcatsoftware/DCIntrospect - its a great tool for debugging UI-related issues. If you push the SPACE-bar in the simulator it gives you the exact positions of all views and more great stuff. As we see, this f*cks with the window hierarchy and messes up the implementation of PopoverView. This problem will not occur when built on a device. However, I recommend a workaround as I am probably not the only one using DCIntrospect in combination with PopoverView :)

from popoverview.

Wirsing84 avatar Wirsing84 commented on July 25, 2024

A possible workaround would be this:

for(UIView *subView in [window subviews]){
    if(!CGRectEqualToRect(subView.frame, CGRectZero)){
        topView = subView;
        break;
    }
}

It works, I'm just not 100% sure of the outcome in other window hierarchies. But it sure is safer than just using objectAtIndex:0

from popoverview.

ocrickard avatar ocrickard commented on July 25, 2024

Hmm, I think it may be safest to add the PopoverView directly to the window. I was thinking about your solution, but I'm concerned that one of the view's layer.zPosition would be set to be below the view stack, resulting in an invisible PopoverView. The window should always be visible. I'll push shortly with the fix.

from popoverview.

Wirsing84 avatar Wirsing84 commented on July 25, 2024

Sounds like a good plan :)

from popoverview.

ocrickard avatar ocrickard commented on July 25, 2024

ce6843c

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.