Sam*_*ikh 7 iphone objective-c uitextview ios
我想在UITextView上使用addTarget:action,如on(UITextField或UIButton).
我想在UITextView上调用一个方法.
请给出一些可能的解决方案
谢谢...
UITextView *TXT_First_Tag = [[UITextView alloc] initWithFrame:CGRectMake(5, textPosY, 350, 65)];
TXT_First_Tag.backgroundColor = [UIColor whiteColor];
TXT_First_Tag.font = [UIFont fontWithName:@"Arial-BoldMT" size:30.0];
TXT_First_Tag.editable =YES;
TXT_First_Tag.tag = i;
TXT_First_Tag.textColor = [UIColor blackColor];
[TXT_First_Tag addTarget:self action:@selector(C6Loop) forControlEvents:UIControlEventEditingDidEnd]; // This Line I want to use, it's working fine on textfield...
[scrollview addSubview:TXT_First_Tag];
Run Code Online (Sandbox Code Playgroud)
小智 11
为此,我们使用UITextView委托方法.
把它放在你的代码中.
UITextView *TXT_First_Tag = [[UITextView alloc] initWithFrame:CGRectMake(5, textPosY, 350, 65)];
TXT_First_Tag.backgroundColor = [UIColor whiteColor];
TXT_First_Tag.font = [UIFont fontWithName:@"Arial-BoldMT" size:30.0];
TXT_First_Tag.editable =YES;
TXT_First_Tag.delegate = self;
TXT_First_Tag.tag = i;
TXT_First_Tag.textColor = [UIColor blackColor];
[scrollview addSubview:TXT_First_Tag];
- (void)textViewDidBeginEditing:(UITextView *)textView{
NSLog(@"Begin editing");
}
- (void)textViewDidEndEditing:(UITextView *)textView{
NSLog(@"DidEndEditing");
}
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
NSLog(@"ShouldBeginEditing");
return TRUE;
}
- (BOOL)textViewShouldEndEditing:(UITextView *)textView{
NSLog(@"ShouldEndEditing");
return TRUE;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11722 次 |
| 最近记录: |