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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.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 UIView在缩放时未检测到触摸_Iphone_Ios_Scale - Fatal编程技术网

Iphone UIView在缩放时未检测到触摸

Iphone UIView在缩放时未检测到触摸,iphone,ios,scale,Iphone,Ios,Scale,我有一个视图,它的子视图是UIScrollView,并且有一个UIImageView,它是UIScrollView的子视图。当我尝试缩放UIView时,UIScrollView和UIImageView也在缩放。但问题是我接触到了视图的一半 这是我的密码 [UIView animateWithDuration:0.5 delay:0.0 options:0 animations:^{ CGFloat DesiredWidth = 250.0; CGFloat DesiredHeight =

我有一个视图,它的子视图是
UIScrollView
,并且有一个
UIImageView
,它是
UIScrollView的子视图。
当我尝试缩放
UIView
时,
UIScrollView
UIImageView
也在缩放。但问题是我接触到了视图的一半

这是我的密码

[UIView animateWithDuration:0.5 delay:0.0 options:0 animations:^{ 
CGFloat DesiredWidth = 250.0;
  CGFloat DesiredHeight = 300.0;
    CGAffineTransform scalingTransform1;
                scalingTransform1 = CGAffineTransformMakeScale(DesiredWidth/self.view1.bounds.size.width,
    DesiredHeight/self.view1.bounds.size.height);
                self.view1.transform = scalingTransform1;
                self.view1.center=CGPointMake(268, 250); }completion:^(BOOL finished) 
             {   }];
请任何人告诉我怎样才能联系到我。我找了很多,但都找不到


谢谢

我认为您的问题在于视图的根UIView(即您所谈论的UIView的超级视图)的大小。当某个子视图大于其superview时,它将不会在其帧的该部分接收超出superview帧的触摸事件

如果您阅读过iOS中的响应程序链,您应该知道UIView会按子视图的排列顺序调用-[hitTest:withEvent:]。此方法检查UIView框架内的某个触摸点,然后开始检查某个子视图是否可以按照它们在响应器链中的位置(本例中为视图层次)处理触摸事件

因此,当触摸事件第一次收到某个UIView first hit测试时,当触摸的位置在其框架之外时,它不会检查其子视图。因此,请仔细检查所有视图的框架,以及某个根视图(可能是您使用的UIViewController的视图属性)是否实际小于您所接触的子视图

还要注意变换。文档中指出,当应用某些变换时,视图的框架变得不相关

总结一下我的回答,让我们看看这种情况:

some_superview.frame = CGRectMake(0, 0, 200, 200);
some_subview_of_the_superview.frame = CGRectMake(0, 0, 200, 300);

在子视图的实际区域(0、200、200、100)中,即底部100个点,超视图将忽略这些接触,因为它们位于超视图的框架之外

请确保。。子视图的框架位于其superview内。如果走错了路。。它不会检测到任何触摸。

您的视图高度和宽度是多少?视图高度是300,宽度是250