Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.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
Objective c UITextField委托方法中的动画不执行_Objective C_Iphone - Fatal编程技术网

Objective c UITextField委托方法中的动画不执行

Objective c UITextField委托方法中的动画不执行,objective-c,iphone,Objective C,Iphone,单击文本框txtAge时,会调用委托方法,但不会执行动画: -(void)textFieldDidBeginEditing:(UITextField *)textField { NSLog(@"field Edited"); if (textField.tag == 0) { NSLog(@"IF Block "); [UIPickerView beginAnimations:nil context:nil]; [UIPicke

单击文本框txtAge时,会调用委托方法,但不会执行动画:

-(void)textFieldDidBeginEditing:(UITextField *)textField {

    NSLog(@"field Edited");
    if (textField.tag == 0) {
        NSLog(@"IF Block ");
        [UIPickerView beginAnimations:nil  context:nil];
        [UIPickerView setAnimationDuration:0.3];
        PkrView .frame = CGRectMake(0, 450, 414, 215);
    }
    else
    {
        NSLog(@" else");
    }
    return; }
你能找出原因吗?

你错过了委托电话。然而,引用苹果关于beginAnimations的文档:

iOS 4.0及更高版本不鼓励使用此方法。您应该使用基于块的动画方法来指定动画

应按照以下方式转换动画:

[UIPickerView animateWithDuration:0.3 animations:^{
    self.view.frame = CGRectMake(0, 450, 414, 215);
} completion:^(BOOL finished){
    // optional, do something after animation completed
}];

欢迎来到Facebook,对于非xcode IDE相关的问题不要使用xcode标签。你能把你的问题改一下吗?你肯定错过了很多东西。花点时间看看。