简体   繁体   English

UIView动画不适用于文本,开始在iPhone App中进行编辑

[英]UIView animation not working on text begin editing in iphone app

I am making the iPad app in which I want to show animation when I start click on beginEditing here is the my code. 我正在制作iPad应用程序,当我开始单击“ beginEdit”时要在其中显示动画。这是我的代码。

-(void)textFieldDidBeginEditing:(UITextField *)textField
{
    NSLog(@"This is calling");
    [self showAnimationPests];
}

-(void) showAnimationPests
{
    [UIView animateWithDuration:0.5
                     animations:^{
                         subView.frame = CGRectMake(0,-200,1024,748);

                     }];
}

It shows Log this is calling but view does not move. 它显示正在调用日志,但视图不会移动。

If it's an iphone app why is the size of it 1024x748 ? 如果它是iPhone应用程序,为什么尺寸为1024x748

CGRectMake takes points not pixels (if you are trying to make up for retina display). CGRectMake取点而不是像素(如果您要弥补视网膜显示)。 And those points for iPhone 5 are 320x568 and previous devices 320x480 . iPhone 5的这些点是320x568和以前的设备320x480

try with my bellow code 尝试下面的代码

Example.. 例..

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    subView.frame = CGRectMake(0,-200,1024,748);
    [UIView commitAnimations];
    return YES;
}

and set to 0 like default in textFieldShouldReturn: method like bellow.. 并设置为0(如textFieldShouldReturn:默认值一样)。

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.3];
        subView.frame = CGRectMake(0,0,1024,748);
        [UIView commitAnimations];
        return YES;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM