Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何使图像在滚动视图中可缩放?_Iphone_Objective C_Image_Uiscrollview_Zooming - Fatal编程技术网

Iphone 如何使图像在滚动视图中可缩放?

Iphone 如何使图像在滚动视图中可缩放?,iphone,objective-c,image,uiscrollview,zooming,Iphone,Objective C,Image,Uiscrollview,Zooming,我希望我的图片名为bildfraga可以缩放。它被放置在名为scroll的scroll视图中。 我可以滚动图片,但不能缩放 显示图像时,这是我的代码: bildfraga = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dtk2.png"]]; scroll.contentSize = bildfraga.frame.size; [scroll addSubview:bildfraga]; scroll.minimumZo

我希望我的图片名为bildfraga可以缩放。它被放置在名为scroll的scroll视图中。 我可以滚动图片,但不能缩放

显示图像时,这是我的代码:

  bildfraga = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dtk2.png"]];
scroll.contentSize = bildfraga.frame.size;
[scroll addSubview:bildfraga];
scroll.minimumZoomScale = 0.4;
scroll.maximumZoomScale = 4.0;
[scroll setZoomScale:scroll.minimumZoomScale];

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scroll{
return bildfraga;
 } 
但当我试图构建它时,会出现一个错误,比如:“使用未声明的标识符‘viewForZoomingInScrollView’”

提前谢谢


/noob这可能就是问题所在。您是否在.h文件中添加了UIScrollViewDelegate?

否我该怎么做O我已经编写了IBMOutlet UIScrollView,但这不是你的意思,对吗?我添加了一行,所以现在是这样:@interface DTK:UIView仍然是相同的问题!在将委托放置在.h文件中之后,您必须将ScrollView对象委托设置为存储委托方法的任何类,我这样说是因为如果对象响应相同,您不必让每个视图都为某个对象持有委托,但暂时不要管它。因此,您应该添加[scroll setDelegate:self];在上面的代码中,我添加了这一行:[scroll setDelegate:self];在setzoomscale行下,但它仍然不起作用:S