small medium large xlarge

Generic-user-small
10 Sep 2009, 22:06
Joshua (4 posts)

I have an app that I am building that places subviews into an nsview. Each subview is an nsview with a bunch of ui controls. I was having problems scaling the view. I tried everything. I then discovered that removing the setwantslayer:yes causes the scaling to work properly. I do lose all core animation abilities though.

I built a test app that created a simple window. I then placed an NSButton into the window. I created another as a subview of an NSBox and a third as a subview of an NSView.

I then scaled each by scaling the frame and then calling scaleUnitSquareToSize. To be sure I also setNeedsDisplay:YES on each button. It works perfectly except when I turn setwantslayer:yes on the nsview. It appears that the frame and bounds of the button don’t get updated properly. I get arbitrary and strange results.

In my actual application, the subviews are not scaled at all properly or even touched.

This seems to be a considerable bug. Am I missing something? Is there a workaround?

Thanks

Josh

Biopic_100x100_pragsmall
11 Sep 2009, 11:41
Bill Dudney (917 posts)

Hi Joshua,

This does indeed sound like a bug.

If you’d like to post the sample code I’d be happy to take a look when I have time.

Also it is very important to post this to bugreporter.apple.com along with the sample code. If it is a bug you will be in the queue to get fixed, if its something in your code more times than not they tell you what is going wrong in the report back to tell you its not a bug.

Good luck!

Generic-user-small
11 Sep 2009, 13:43
Joshua (4 posts)

I have already opened a bug with apple. I tried the cocoa-dev list as well with no luck.

Here is a link to my test project ScaleTest.zip

Biopic_100x100_pragsmall
11 Sep 2009, 16:05
Bill Dudney (917 posts)

Hi Joshua,

I don’t have time to look at the code right now but it looks to me like a bug in your scaling code that just happens to work ok on ‘normal views’. The button does scale, but only after the second click of scale up. Then on the way back down I get strange behavior for the first and mostly the second click but then it looks OK.

Are you calling setNeedsLayout on the view? Are you using your own layer or the layer that the view owns? If you are using the layer the view owns only act on it though the view’s api’s not the layer its self.

Good luck! If I get time to look at the code I’ll post back here.

Generic-user-small
11 Sep 2009, 19:10
Joshua (4 posts)

I am not calling setNeedsLayout at all. I am not directly operating on the layers. This simple app just uses interface builder to set up the hierarchy. I just tried modifying the app to call setNeedsLayout on the view.layer and no luck. It changes randomly as before. I also tried directly calling setNeedsLayout on the button too. Love to see what you come up with.

Generic-user-small
11 Sep 2009, 19:13
Joshua (4 posts)

One more thing. Even when the button scales correctly with setWantsLayer:YES, sometimes when you click on it, its view gets corrupted like the others.

You must be logged in to comment