Comments (6)
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.
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.
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.
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.
Sounds like a good plan :)
from popoverview.
from popoverview.
Related Issues (20)
- Not working in landscape mode HOT 2
- topView may be hidden HOT 4
- SplitViewController in portrait - popover appears behind mainView on detailView HOT 14
- Method of getting topView fails when using with DCIntrospect - popover doesn't appear HOT 6
- Proper device orientation not always recognized HOT 1
- Broken link HOT 5
- UITableView not responding to first tap HOT 6
- Tap below to dismiss? HOT 3
- Ensure only one Popoverview open at time? HOT 1
- Don't disable other gestures when the popover is showing HOT 2
- CocoaPods/Specs/PopoverView is out of date HOT 4
- Would be nice to have an option to not to display arrow
- content view is not scrollable? HOT 2
- Don't support scroll when there're many items
- when I press button a little quick, eg
- when I press button a little quick, e.g. double click, then
- how to setting the directions of the popoverView.
- help!my contentView is build with XIB HOT 2
- interactive with SVProgressView
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from popoverview.