Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3794166
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:53:16+00:00 2026-05-19T12:53:16+00:00

I have a view. this view has a wheel in the middle. it also

  • 0

I have a view. this view has a wheel in the middle. it also supports iAds and auto rotation. so whenever an ad pops in the top, or the device rotates, the wheel automatically repositions itself to the centre of the open space.

Now I have a class to detect if the user is spinning the wheel round. it is derived from UIAdvancedGesture, but in order for it to work correctly it needs to know the centre of the wheel. Which keeps changing. how to fix?

I would like to ‘ observe ‘ myObject.myCALayer.center, and every time it changes, send the new value into my touchinput-processing class.

so I have done this:

- (id) initWithFrame: (CGRect) theFrame
              target: (id) p_target
     actionPlayChord: (SEL) p_actionPlayChord
      actionSettings: (SEL) p_actionSettingsClick
{
    target = p_target;
    actionPlayChord = p_actionPlayChord;

    self = [super initWithFrame: theFrame];

    if ( ! self )
        return nil;

    CGPoint centre = CGPointMake(theFrame.size.width / 2.0, theFrame.size.height / 2.0);

    WheelTouchHandler * wheelTouchHandler = [WheelTouchHandler alloc];
    [wheelTouchHandler initWithTarget: self 
                       activateAction: @selector(engaged:)
                         moveCWAction: @selector(movedCW:)
                        moveACWAction: @selector(movedACW:)
     ] ;

    [self addGestureRecognizer: wheelTouchHandler];

    [self setMultipleTouchEnabled: NO];


    self.wheel = [Wheel alloc];

    NSUserDefaults * prefs = [NSUserDefaults standardUserDefaults];
    NSString *symbol = [prefs stringForKey: @"sharpsOrFlats"];

    [self.wheel init_rMax: WHEEL_R_MAX
                     rMin: WHEEL_R_MIN
                   rGap01: WHEEL_R_RATIO_GAP_TO_DISC
                   rRatio: WHEEL_R_RATIO_OUTER_TO_INNER
              sharpsFlats: symbol
               bitmapSize: theFrame.size 
     ] ;

    [self.layer addSublayer:  [self.wheel wheelLayer] ];

    [self.wheel.wheelLayer setPosition: centre ];


    [self.layer addSublayer:  [self.wheel labelLayer] ];
    [self.wheel.labelLayer setPosition: centre ];

    // "center" fails too...
    [self.wheel.wheelLayer addObserver:self forKeyPath:@"position" options:0 context:nil];


    return self;
}

- (void)observeValueForKeyPath:(NSString *)keyPath 
                      ofObject:(id)object 
                        change:(NSDictionary *)change 
                       context:(void *)context
{
    NSLog(@"Changed!"); <--  this line does not get hit - why?
}

However, nothing gets logged. what am I doing wrong? Obviously the wheel’s CALayer repositions itself on the screen. but the Observer fails to observe this change. How to fix?

UPDATE:
apparently there is some issue with KVO on CALayer properties.

I have tried subclassing CALayer, like this:

@implementation WatchedLayer

+(BOOL) automaticallyNotifiesObserversForKey: (NSString *) key
{

    //, if key is @"position" return YES, otherwise return [super automatically...]

    if ([key isEqual: @"position"])
        return YES; // doesn't get hit

    if ([key isEqual: @"center"])
        return YES; // <-- gets hit

    return [super automaticallyNotifiesObserversForKey: key];
}

- (void) setValue: (id) value 
           forKey: (NSString *) key
{
    // method doesn't get hit


    if ([key isEqual: @"position"])
    {
        NSLog(@"POSHIT");
    }

    [super setValue: value 
             forKey: key];
}

@end

but still no joy

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:53:17+00:00Added an answer on May 19, 2026 at 12:53 pm

    Some of the CALayer properties are not KVO compliant. The frame property, for example, for CALayer’s appears to be one of those properties. I’ve successfully observed changes to the bounds property (CGRect) instead which is KVO compliant (at least in 10.6).

    I’ve also tested the position property and it is KVO compliant on 10.6. I’m not sure about 10.5 and iOS though.

    It seems there are differences in KVC/KVO compliant properties for CALayer’s between 10.5 and 10.6. Specifically, custom properties of CALayer subclasses appear not to be KVO compliant in 10.5, but are compliant in 10.6. There may be other KVO compliance differences between CALayer properties between 10.5, 10.6, and iOS.

    http://lists.apple.com/archives/cocoa-dev/2008/Dec/msg01141.html

    and

    http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/Layers.html%23//apple_ref/doc/uid/TP40006082-SW1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.