如何向 UITextview 添加动作?
How to add an action to UITextview?
我希望 UITextView
中的文本在用户单击 UITextView
时更改。
我怎样才能以编程方式做到这一点。
您需要使用 UITextViewDelegate。
在这个方法中:
- (void)textViewDidBeginEditing:(UITextView *)textView
{
textView.text = @"Your text";
}
在Swift中你可以使用:
func textFieldDidBeginEditing(_ textField: UITextField)
{
textField.text = "Some text";
}
同时检查下面的 link:
我希望 UITextView
中的文本在用户单击 UITextView
时更改。
我怎样才能以编程方式做到这一点。
您需要使用 UITextViewDelegate。
在这个方法中:
- (void)textViewDidBeginEditing:(UITextView *)textView
{
textView.text = @"Your text";
}
在Swift中你可以使用:
func textFieldDidBeginEditing(_ textField: UITextField)
{
textField.text = "Some text";
}
同时检查下面的 link: