UIImageView 不允许我放大图像
我正在使用以下代码在图像视图中加载图像。但它不允许我捏或缩放或任何东西。有什么想法如何修复它吗?
NSURL *url = [NSURL URLWithString:self.myURL];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[[UIImage alloc] initWithData:data] autorelease];
self.imageView.image = img;
I'm using the following code to load an image in an image view. But it is not letting me pinch or zoom or anything. Any ideas how to fix it?
NSURL *url = [NSURL URLWithString:self.myURL];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[[UIImage alloc] initWithData:data] autorelease];
self.imageView.image = img;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
幸运的是,Apple 为您编写了一个 ImageScrollView 类。
http://developer.apple.com/library/ios/ #samplecode/PhotoScroller/Listings/Classes_ImageScrollView_h.html
http://developer.apple.com/library/ios/#samplecode /PhotoScroller/Listings/Classes_ImageScrollView_m.html
您可以编辑它们使用的 UIImageView 的 TilingView 子类,而只使用普通的 UIImageView
Lucky for you, Apple wrote an ImageScrollView class for you.
http://developer.apple.com/library/ios/#samplecode/PhotoScroller/Listings/Classes_ImageScrollView_h.html
http://developer.apple.com/library/ios/#samplecode/PhotoScroller/Listings/Classes_ImageScrollView_m.html
You can edit out the TilingView subclass of UIImageView they use and just use a normal UIImageView
将 UIImageView 放置在 UIScrollView 中并实现放大和缩小方法。
Place your UIImageView within a UIScrollView and implement the zoom in and out methods.
它不会自动让您缩放或“任何东西”。你必须对其进行编程。使用 UIGestureRecognizer 识别捏合手势,或者您可以将其放置在 UIScrollView 中并启用缩放和/或平移。
It does not automatically let you zoom or "anything". You have to program that. Use UIGestureRecognizer to recognize the pinch gesture, or you can place it in a UIScrollView and enable zooming and/or panning.