small medium large xlarge

Generic-user-small
03 Nov 2009, 18:41
Sebastian (2 posts)

Hi,

I tried running the ‘MenuLayout’ example (i.e. FrontRow like menus example from the CA book) and it is not behaving as it should.

The menu items are not properly highlighted, and upon selection, move up to the the top of the view where they ‘collapse’ on top of each other…

Running 10.6, I tried both building for 10.5 and 10.6 targets…

Any suggestions?

Thanks,

Sebastian

Biopic_100x100_pragsmall
04 Nov 2009, 13:59
Bill Dudney (917 posts)

Hi Sebastian,

Looks like in 10.6 they changed the way constraints work. The layers are disappearing because the highlight layer’s frame is zero high and that is causing the superlayer’s frame to go zero high. Woking on a workaround.

Biopic_100x100_pragsmall
04 Nov 2009, 14:12
Bill Dudney (917 posts)

Hi Sebastian,

Instead of constraining the height for the highlight and reflection layers we have to constrain the min and max x and y.

~~~ [highlightLayer addConstraint: [CAConstraint constraintWithAttribute:kCAConstraintMinX relativeTo:@"superlayer" attribute:kCAConstraintMinX]]; [highlightLayer addConstraint: [CAConstraint constraintWithAttribute:kCAConstraintMaxX relativeTo:@"superlayer" attribute:kCAConstraintMaxX]]; [highlightLayer addConstraint: [CAConstraint constraintWithAttribute:kCAConstraintMinY relativeTo:@"superlayer" attribute:kCAConstraintMinY]]; [highlightLayer addConstraint: [CAConstraint constraintWithAttribute:kCAConstraintMaxY relativeTo:@"superlayer" attribute:kCAConstraintMaxY]]; ~~~

And then later in that same method;

~~~ [reflectionLayer addConstraint: [CAConstraint constraintWithAttribute:kCAConstraintMinX relativeTo:@"superlayer" attribute:kCAConstraintMinX]]; [reflectionLayer addConstraint: [CAConstraint constraintWithAttribute:kCAConstraintMaxX relativeTo:@"superlayer" attribute:kCAConstraintMaxX]]; [reflectionLayer addConstraint:// <label id="code.MyController.reflectionLayer.midY"/> [CAConstraint constraintWithAttribute:kCAConstraintMinY relativeTo:@"superlayer" attribute:kCAConstraintMidY offset:0]]; [reflectionLayer addConstraint:// <label id="code.MyController.reflectionLayer.midY"/> [CAConstraint constraintWithAttribute:kCAConstraintMaxY relativeTo:@"superlayer" attribute:kCAConstraintMidY offset:40.0f]]; ~~~

I’ll look at a different approach than using 40 as a hardcoded value but figured it’d be better to get something to you quicker.

Good luck!

Head_only_pragsmall
07 Nov 2009, 02:49
Sean P. DeNigris (17 posts)

I tried the workaround and the behavior didn’t change. They still squished up at the top of the view w/o proper effects. OS X 10.6.1

Biopic_100x100_pragsmall
07 Nov 2009, 12:56
Bill Dudney (917 posts)

Hi Sean,

Strange it worked for me after this change in 10.6.1. Any other changes?

Weiss_02_pragsmall
28 Dec 2009, 17:45
tps (1 post)

Hi Bill, I was having the same problem with this example, but the above workaround did not do it for me (on 10.6.2). I tried now to work it out by myself and I found that, as you said, the height of the reflection and the highlight layer remain zero despite the fact that they’re constrained to the superlayer’s height. And when the highlight layer is added as sublayer to a menu layer, it causes said menu layer’s height to become zero too. Now I found that this can be prevented by initially setting the reflection layer’s height:

/* in -(CALayer*)highlightLayer */
[reflectionLayer setValue:[NSNumber numberWithFloat:43.0f] forKeyPath:@"frame.size.height"]; 
/* 43 is the height of a menu layer */

Now there are two things I don’t understand about this problem: 1. Why is the height of the reflection and highlight layers not set to the correct value (I mean, we added constraints for that, so it should)? 2. And why does the sublayer even influence the superlayer’s height? I thought that the layout manager determines the sublayers size depending on the superlayer’s size (if the relationship is set to be between superlayer and sublayer) and not the other way around.

Biopic_100x100_pragsmall
30 Dec 2009, 12:24
Bill Dudney (917 posts)

Hi Tobias,

I’m not positive why what is happening is happening but they changed the way layout managers work in Snow Leopard and that is what is breaking this code.

My guess is that the change was required to fix some bug and a side effect of the bug fix was that now we have to explicitly size more layers that we had to in Leopard.

I should have time early in the new year to rework this example and when I do I’ll post what I find to my blog.

Good luck!

You must be logged in to comment