Closed palringosteve closed 12 years ago
Hello Steve,
I don't have an iOS 4 device or simulator sitting around, and don't have any apps that support iOS 4. I am running Lion on all my dev machines so I can't install the older Xcode to use the iOS 4 simulator without a lot of hassle. I may be using some code introduced in iOS 5+ or perhaps my assumption about the order of views isn't valid in iOS 4. If you would provide more information I can perhaps diagnose this problem from afar. Does it crash? Did you check if the drawRect function is being called? Are there other overlay views that may be interfering with the display of the popover such as the dimming view it would appear you're using here?
Thanks, Oliver
mine, tested on simulator 4.3, it's not crash and draw rect function is being called, but the title background is not appear and also the background of view does not appear.
iPhone Simulator 4.3 http://dl.dropbox.com/u/95307763/Screen%20Shot%202012-10-09%20at%208.41.03%20AM.png
iPhone Simulator 5.1 http://dl.dropbox.com/u/95307763/Screen%20Shot%202012-10-09%20at%208.41.31%20AM.png
As tuanadi has stated, it does not crash and the drawRect function does get called. I haven't tried reducing the variables by creating a test app with just the PopoverView, though it looks like tuanadi has and is experiencing the same issues.
One thing I do notice from tuanadi's examples is that the backgrounds are drawn for each of the items, but not the title/background/arrow. This is also inline with my issues as I use just the title.
After researching this a little bit more, it would appear that the problem is actually with the color declarations for the gradient. Right now the top and bottom gradient fill colors are specified as something like this:
[UIColor colorWithWhite:1.f alpha:kBoxAlpha]
Then these colors are converted to a CGColorRef through the CGColor
selector on these UIColors. In iOS 4, my understanding is that these C structs (the CGColorRefs) are fundamentally different when created using the colorWithWhite:alpha:
selector. [1] It would appear that the issue may be resolved by replacing the above line (and all other UIColor references) with:
[UIColor colorWithRed:1.f green:1.f blue:1.f alpha:kBoxAlpha]
Would you guys mind testing this for me to see if this is the issue? If so, I'll update my code and push to GitHub.
Oliver
[1] : http://stackoverflow.com/questions/10926919/cggradientcreatewithcolors-not-working-on-ios-4-anymore
Amazing find! I can confirm that switching from colorWithWhite:alpha:
to colorWithRed:green:blue:alpha
works like a charm :D
Since you did the hard work I've sent you a pull request with the fix. https://github.com/runway20/PopoverView/pull/7
The popover view does not render the background correctly on iOS 4 (tested on 4.3.5 iPhone 3GS).