Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.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
Ios UIView animateWithDuration不';t使用矩形宽度/高度动画_Ios_Ios5 - Fatal编程技术网

Ios UIView animateWithDuration不';t使用矩形宽度/高度动画

Ios UIView animateWithDuration不';t使用矩形宽度/高度动画,ios,ios5,Ios,Ios5,以下代码有效。它可以很好地为所有这些组件设置动画 CGRect logoRect = self.logoImageView.frame; CGRect loginBackgroundRect = self.loginControlsBkImageView.frame; CGRect loginButtonRect = self.loginButton.frame; CGRect tableViewRect = self.tableView.frame; CGRect forgotPassword

以下代码有效。它可以很好地为所有这些组件设置动画

CGRect logoRect = self.logoImageView.frame;
CGRect loginBackgroundRect = self.loginControlsBkImageView.frame;
CGRect loginButtonRect = self.loginButton.frame;
CGRect tableViewRect = self.tableView.frame;
CGRect forgotPasswordRect = self.forgotButton.frame;
CGRect signupButtonRect = self.signUpButton.frame;


if (!iPhone) {

    // ipad keyboard-on-screen re-layout

    logoRect.origin.y-= 60;
    loginBackgroundRect.origin.y-= 110;
    loginButtonRect.origin.y-=110;
    tableViewRect.origin.y-=110;
    forgotPasswordRect.origin.y-=110;
    signupButtonRect.origin.y-=200;

}
else {

    // iphone keyboard-on-screen re-layout

    if (portrait) {
        logoRect.origin.y-=17;
        logoRect.origin.x-=50;
        loginBackgroundRect.origin.y-= 70;
        loginButtonRect.origin.y-=70;
        tableViewRect.origin.y-=70;
        forgotPasswordRect.origin.y-=70;
        //signupButtonRect.origin.y+=200; // get off screen!
    } else {
        logoRect.origin.y-= 30;
        loginBackgroundRect.origin.y-= 25;
        loginButtonRect.origin.y-=25;
        tableViewRect.origin.y-=25;
    }
}    


[UIView animateWithDuration:0.2f
                      delay:0.0f
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^(void) {
                     self.logoImageView.frame = logoRect;
                     self.loginControlsBkImageView.frame = loginBackgroundRect;
                     self.loginButton.frame = loginButtonRect;
                     self.tableView.frame = tableViewRect;
                     self.forgotButton.frame = forgotPasswordRect;
                     self.signUpButton.frame = signupButtonRect;
                 }
                 completion:NULL];
获取以下代码并添加一行(见下文)以设置logoImageView宽度的动画。。。还有吹气。。。只有logoImageView动画起作用-其余部分根本不移动。如果在同一动画块中,帧大小动画会使其他所有内容都不动画化

if (portrait) {
        logoRect.origin.y-=17;
        logoRect.origin.x-=50;
        loginBackgroundRect.origin.y-= 70;
        loginButtonRect.origin.y-=70;
        tableViewRect.origin.y-=70;
        forgotPasswordRect.origin.y-=70;
        //signupButtonRect.origin.y+=200; // get off screen!
    } else {
        logoRect.origin.y-= 30;
        logoRect.size.width-= 30;   // <------- LINE BEING ADDED HERE

        loginBackgroundRect.origin.y-= 25;
        loginButtonRect.origin.y-=25;
        tableViewRect.origin.y-=25;
    }
if(纵向){
logrect.origin.y-=17;
logrect.origin.x-=50;
loginBackgroundRect.origin.y-=70;
loginButtonRect.origin.y-=70;
tableViewRect.origin.y-=70;
forgotPasswordRect.origin.y-=70;
//signupButtonRect.origin.y+=200;//离开屏幕!
}否则{
logrect.origin.y-=30;

logrect.size.width-=30;//尝试更改整个框架,而不仅仅是宽度。它应该可以工作

在提交动画之前放置以下行(不在块中):

并尝试以这种方式使用提交动画,而不是使用动画方法:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
// Here some more animation settings
// Here your animations 
[UIView commitAnimations];

不确定你的意思。我正在更改一个矩形,然后指定帧=矩形。我还应该做什么?这正是我正在做的。看看我的动画块。对不起。仍然不起作用。我甚至敢为一个矩形宽度或高度设置动画,只有该矩形会被设置动画。所有其他动画都将被忽略d、 我不明白为什么。这似乎是一个Cocoa错误。这里解决了:检查geting首先调用哪个方法,或者动画启动后是否设置了帧..猜测:)它与“origin.x”一起工作,“size.width”有什么不同?这真的是计时/线程问题吗?在动画期间更改宽度可能很棘手。通常情况下,帧会更改。
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
// Here some more animation settings
// Here your animations 
[UIView commitAnimations];