私が持っているもの:
を動かすとUIView、次のようにしてその動きを検出しています。
[myView.layer addObserver:self forKeyPath:@"position" options:NSKeyValueObservingOptionNew context:nil];
私は動いていmyViewて、クラスが持っているさまざまな位置を検出する必要があります。UIViewselfUIView
問題:
myView別の中に入れてUIView移動するとanotherView:
[anotherView addSubview: myView];
メソッド:
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context;
理論上myViewは同様に動いていますが、もう呼び出されません。NSNotification「動き」が発生するたびに発射されるようにしようとしましたが、不器用です。この種の問題に対する「エレガントな」解決策はありますか?
の移動には、次のUIViewメソッドを使用しています。
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;