[英]How can I change name of button when I touch textField?
I know that it is a simple question, but I do not know how can I do that. 我知道这是一个简单的问题,但我不知道该怎么办。 I mean I need use gesture or some method and which one?
我的意思是我需要使用手势或某种方法,哪一种? I tried this with FirstResponder and touch events but all they are works not how I need.
我尝试过使用FirstResponder和touch事件,但是所有这些都无法满足我的需要。 And title of button need to be changed only in one way - when I touch textField.
而且按钮的标题仅需要以一种方式更改-当我触摸textField时。 Sorry for my english.
对不起我的英语不好。
Use the UITextField
Delegate : 使用
UITextField
委托:
-(void)textFieldDidBeginEditing:(UITextField *)sender{
//[sender resignFirstResponder];// Resigning the KeyBoard.
[self.myButton setTitle:@"ddd" forState:UIControlStateNormal];
}
Try with below code: 尝试以下代码:
[YourTextField addTarget:self
action:@selector(yourDesiredMethod)
forControlEvents:UIControlEventTouchUpInside];
-(void)yourDesiredMethod
{
[YourButton setTitle:@"YourTitleString" forState:UIControlStateNormal];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.