I want to add UITextView the function of Placeholder, so I do like this:
@interface UIPlaceholderTextView : UITextView <UITextViewDelegate>
{
UILabel *placeholderLabel;
}
And when the text changed in the UITextView, the method is called:
#pragma UITextViewDelegate
-(void)textViewDidChange:(UITextView *)textView
{
if (textView.text.length==0)
{
placeholderLabel.hidden=false;
}
else
{
placeholderLabel.hidden=true;
}
}
In the IOS simulator 6.1 everything is ok. But the programe breakdown when I ran in IOS simulator 5.1, and I find the problem happens here :
self.delegate = self;
It seems that it is not appropriate to make delegate itself. But I don not know the exact reason , and what is the right way to do?