在启用分页和多个图像的情况下缩放 UIScrollView
我有一个 UIScrollview
,其中有一个 UIImageView
,我可以在其中从一个图像滚动到另一个图像。
我使用了 TapToZoom Apple 示例代码 来实现缩放,但每当我缩放时,滚动视图都会从头开始而不是活动图像。
这是我的一段代码:
初始化并填充图像视图:
table = [[NSMutableArray alloc] initWithCapacity:7];
for(int count = 1; count <= 7; count++)
{
NSString *fileName = [NSString stringWithFormat:@"image%d.jpg", count];
UIImage *image = [UIImage imageNamed:fileName];
[table addObject:image];
if (image == nil) {
break;
}
imageView = [[UIImageView alloc] initWithImage:image];
imageView.userInteractionEnabled = YES;
imageView.multipleTouchEnabled = YES;
实现点击手势:
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
handleDoubleTap
方法缩放到imageView
的中心并将滚动视图带到开始寻呼。
我对此进行了很多搜索,但无法找到放大实际显示图像的方法。
提前致谢 :)
I Have a UIScrollview
with a UIImageView
inside where I scroll from an image to another.
I used the TapToZoom Apple sample code to implement the zoom but whenever I zoom the scrollview starts from the begining rather than the active image.
Here's a piece of my code :
Init and populate the imageview :
table = [[NSMutableArray alloc] initWithCapacity:7];
for(int count = 1; count <= 7; count++)
{
NSString *fileName = [NSString stringWithFormat:@"image%d.jpg", count];
UIImage *image = [UIImage imageNamed:fileName];
[table addObject:image];
if (image == nil) {
break;
}
imageView = [[UIImageView alloc] initWithImage:image];
imageView.userInteractionEnabled = YES;
imageView.multipleTouchEnabled = YES;
Implement Tap Gesture :
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
The handleDoubleTap
method zooms to the center of the the imageView
and brings the scrollview to the begigining of the paging.
I searched a lot about this, but was unable to find a way to zoom on the actual displayed image.
Thanks in advance :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 Apple 的 PhotoScroller 示例:
http://developer.apple .com/library/ios/#samplecode/PhotoScroller/Introduction/Intro.html
Checkout the PhotoScroller sample from Apple:
http://developer.apple.com/library/ios/#samplecode/PhotoScroller/Introduction/Intro.html