dug*_*gla 0 iphone cocoa-touch uiscrollview
我想在并行工作的屏幕上有一对scrollview - 称为scrollA和scrollB.当用户滚动/缩放scrollA时,scrollB模仿该行为,缩放和平移相同.反之亦然.
这可能吗?提前致谢.
干杯,道格
根据JoePasq的回答,我会使用KVO并注册观察者,无论你想在每个中模仿哪个键/值对UIScrollView.它看起来像这样(未经测试):
// Do this during initialisation of scrollView2
[scrollView1 addObserver:self
forKeyPath:@"contentOffset"
options:NSKeyValueObservingOptionNew
context:NULL];
[scrollView1 addObserver:self
forKeyPath:@"zoomScale"
options:NSKeyValueObservingOptionNew
context:NULL];
// Implement this method on scrollView2
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
[self setValue:[change valueForKey:NSKeyValueChangeNewKey] forKey:keyPath];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1189 次 |
| 最近记录: |