Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.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 animateWithDuration干扰其他CGRectMake_Iphone_Objective C_Uiview_Uiviewanimation - Fatal编程技术网

Iphone UIView animateWithDuration干扰其他CGRectMake

Iphone UIView animateWithDuration干扰其他CGRectMake,iphone,objective-c,uiview,uiviewanimation,Iphone,Objective C,Uiview,Uiviewanimation,我有一个CGRectMake,用于将图像跳转到不同的位置 image.frane=CGRectMake( x,y,w,h); 然后我想将标签(在同一视图控制器上)转换并缩放到另一个位置 CGPoint newCenter = CGPointMake(x,y); [UIView animateWithDuration: 1.0 delay: 0 options: 0 animations:^{label.center = newCenter ; label.transfo

我有一个
CGRectMake
,用于将图像跳转到不同的位置

image.frane=CGRectMake( x,y,w,h);
然后我想将
标签
(在同一
视图控制器
上)转换并缩放到另一个位置

CGPoint newCenter = CGPointMake(x,y);
[UIView animateWithDuration: 1.0
    delay: 0
    options: 0
    animations:^{label.center = newCenter ; label.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.2, 0.2);}
                     completion:^(BOOL finished) {
                         label.transform = CGAffineTransformMakeScale(1.0, 1.0);
                         label.alpha = 0;
    }
];

我遇到的问题是,当我使用
animateWithDuration
时,图像不会移动,但
标签会移动。如果注释掉动画,图像将再次移动。我做错什么了吗?

试试下面的代码

[UIView animateWithDuration:1.0f animations:^{
    imageView.frame = CGRectMake(newCenter.x, newCenter.y, imageView.frame.size.width, imageView.frame.size.height);
}];
您还可以使用下面的代码移动
UIImageView
或任何其他内容。。。当键盘出现时,我使用此代码滚动
UIScrollView
。。我将代码添加到您的要求中

UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0f];
imageView.frame = CGRectMake(newCenter.x, newCenter.y, imageView.frame.size.width, imageView.frame.size.height);
[UIView commitAnimations];

我希望这对你有帮助…

请你详细说明你的问题和代码。?这是
图像。frane
这里是一个打字错误吗?这也是一个iOS6应用程序,你在使用自动布局吗?谢谢他们的工作。尽管如果我将线添加到setAnimation _label.transform=CGAffineTransformMakeScale(0.2,0.2);它在第一次停止工作时,向CGRectMake添加标尺的最佳方式是什么?我以前没有真正使用过这些,但似乎调整帧的宽度和高度不会随着时间的推移而立即生效。我希望同时翻译和缩放标签,因此可能从pos 100 100到200 200,并缩放到0.5,代码UIView beginAnimations:nil context:nil];[UIView设置动画持续时间:1.0f];imageView.frame=CGRectMake(newCenter.x,newCenter.y,imageView.frame.size.width,imageView.frame.size.height);[UIView委员会];移动对象,但缩放不正确?UIView beginAnimations:nil上下文:nil];[UIView设置动画持续时间:1.0f];imageView.frame=CGRectMake(newCenter.x,newCenter.y,imageView.frame.size.width,imageView.frame.size.height);yourLable.frame=CGRectMake(200200,yourLable.frame.size.width,yourLable.frame.size.height);[UIView委员会]@Cantwell使用上述代码只需添加该行即可更改标签的框架