在我的TextView有「名」如何在UITextView的(iphone)無法進行此操作
我要實現它這樣的操作..默認值爲
1)它應顯示「名字」首先
2)當我開始編輯應該成爲零
3)當我完成我的編輯,如果該領域仍然爲零,那麼它應該顯示爲「名」再次
能任何人都可以幫助我?
// *現在這是什麼,我現在在做** //
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range
replacementText:(NSString *)text
{
if ([email protected]"") {
[email protected]"First Name(Required)";
}
// Any new character added is passed in as the "text" parameter
if ([text isEqualToString:@"\n"]) {
// Be sure to test for equality using the "isEqualToString" message
[textView resignFirstResponder];
// Return FALSE so that the final '\n' character doesn't get added
return FALSE;
}
// For any other character return TRUE so that the text gets added to the view
return TRUE;
return TRUE;
}
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView {
NSLog(@"textViewShouldBeginEditing");
textView.scrollEnabled=NO;
if (textView == first_name) {
first_name.text=nil;
}
return YES;
}
你的意思是一個UITextField?有一個名爲placeHolder的屬性。 –
沒有一個textView .... –
正如esqew下面說的,使用委託方法textViewDidStart/End-Editing –