0

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?

itenyh
  • 1,921
  • 2
  • 23
  • 38

1 Answers1

0

Where do you assign the delegate to itself? I put it in the initWithFrame and it just worked fine (even with iOS 5.1 deployment target)

Peteee24
  • 510
  • 4
  • 8