简体   繁体   中英

how do I set a delegate in a view that is not my main view

I have a xib. the xib has a button that swaps another xib.

the second xib has a uitextfield and a uilabel.

how do I make the keyboard go away when I'm done typing? what do I need to wire or code? the second xib has it's own class (called CustomSign.m)

Inside CustomSign.m, I've implemented the following method

-(void)textFieldDidEndEditing:(UITextField *)textField {
[customText resignFirstResponder];
signedLabel.text = customText.text;
}

- (void)awakeFromNib
{
//assume textField is an ivar that is connected to the textfield in IB
[customText setDelegate:self];
}

I get the following warning

Class "CustomSign" does not implement the UITextFieldDelegate protocol

To remove warning you need to specify in your CustomSign class declaration that it conforms to UITextFieldDelegate protocol:

@interface CustomSign: UIViewController<UITextFieldDelegate>
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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