开发者

TextField clear button

I have 5 textField popovers that are all dependant on each other. The value in the first field sets what will show in popover for second field and so on...

If the user removes one of the fields, I want 开发者_如何学JAVAto be able to clear all fields following that are linked to this field. I started by using the textFieldShouldClear method, but I can't seem to figure out how to tell it which textField is being cleared. It either clears everything, or doesn't clear at all.

Thanks


It sounds like your textFields are set up in IB, which means you can declare 5 IBOutlet UITextField objects in your header file and hook these up to the fields in IB. Then in your delegate method, you can do something like this:

- (BOOL)textFieldShouldClear:(UITextField *)textField {
    if([textField isEqual:myField1]) {
        myField2.text=@"";
        myField3.text=@"";
        ...
    }
    else if([textField isEqual:myField2]) {
        myField3.text=@"";
        ...
    }
     //etc....
    return YES;
}

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜