【发布时间】:2013-12-18 06:59:35
【问题描述】:
在 Scroll-View 中有一个 Child-View 并在 Scroll on Top、Left、Right 中遇到问题?
在子子视图中添加捏合和缩放的代码
UIPinchGestureRecognizer *twoFingerPinch = [[[UIPinchGestureRecognizer alloc]
initWithTarget:self
action:@selector(twoFingerPinch:)]
autorelease];
[_childView addGestureRecognizer:twoFingerPinch];
捏和缩放子视图的方法
- (void)twoFingerPinch:(UIPinchGestureRecognizer *)recognizer
{
//NSLog(@"Pinch scale: %f", recognizer.scale);
CGAffineTransform transform = CGAffineTransformMakeScale(recognizer.scale, recognizer.scale);
// you can implement any int/float value in context of what scale you want to zoom in or out
_childView.transform = transform;
_scrollView.contentSize =
CGSizeMake(_scrollView.frame.size.width,_childView.frame.size.height);
}
Scroll-View ContentSize 设置有什么问题吗?
这是我的代码
谢谢
【问题讨论】:
-
您能详细说明一下视图层次结构吗?
-
您阅读过滚动视图编程指南吗? developer.apple.com/library/ios/documentation/WindowsViews/… 它描述了如何设置滚动视图以进行缩放和滚动。
-
@Chancy SuperView -> ScrollView --> ChildView.
标签: ios objective-c uiscrollview contentsize