uitextfield,需要算术或指针类型。

时间:2015-05-05 12:32:05

标签: ios objective-c uitextfield pointer-arithmetic

我有以下代码,并在屏幕截图中显示错误。这个错误意味着什么

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if (textField.tag<10) {

        if ((textField.text.length >= 1) && (string.length > 0))
        {

            NSInteger nextText = textField.tag + 1;
            // Try to find next responder
            UIResponder* nextResponder = [textField.superview viewWithTag:nextText];
            if (! nextResponder)
                [textField resignFirstResponder];
               // nextResponder = [textField.superview viewWithTag:1];

            if (nextResponder){
                // Found next responder, so set it.
                [nextResponder becomeFirstResponder];

                UITextField* nextTextfield= (UITextField) [textField.superview viewWithTag:nextText];
                [nextTextfield setText:string];
                return NO;

            }

        }
    }

    return YES;

}

我在以下情况下遇到以下错误。我无法找到解决方案

enter image description here

1 个答案:

答案 0 :(得分:1)

UITextField应设置为指针(*符号),如下所示:

UITextField* nextTextfield = (UITextField *) [textField.superview viewWithTag:nextText];