我在UITextView
处使用resignFirstResponder,当我触摸返回但它不起作用
我的代码
CommentViewController.h
@interface CommentViewController : UIViewController<UIImagePickerControllerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UITextViewDelegate>
{
IBOutlet UITextView *commentText;
}
CommentViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
commentText.delegate =self;
}
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if ([text isEqualToString:@"/n"]) {
[textView resignFirstResponder];
return NO;
}
else
return YES;
}
答案 0 :(得分:1)
确保声明对UITextViewDelegate协议的支持。
window.onload = function () {
[ ... ]
var button = document.createElement("BUTTON");
button.id = "BUTTON_ID";
button.onclick = function() {
alert("Clicked");
}
table.appendChild(button);
[ ... ]
}
答案 1 :(得分:0)
我认为你的问题是换行符。它不应该是/n
而是\n
。
如果这不起作用,我建议在if
行中设置断点,并查看代码的步骤。
快乐的编码! ž。