removeFromSuperView not working with UITextView

I am trying to use removeFromSuperView with a UITextView Object but it is giving me the following error:


No visible @interface for 'UITextField' declares the selector 'removeFromSuperView'


This seems strange since UITextField is a subclass of UIView, so it should inherit the removeFromSuperView method. I have tried the same method for buttons and it works great. Here is how I am calling it:


[self.exitButton removeFromSuperview];

[self.teacherText removeFromSuperView];


I set up my UITextField programmatically, it is declared as follows:

in .h:

@property(nonatomic, copy) UITextField *teacherText;

in viewDidLoad of .m:

_teacherText = [[UITextField alloc] initWithFrame:CGRectMake(45, 30, 200, 40)];

_teacherText.textColor = [UIColor colorWithRed:0/256.0 green:84/256.0 blue:129/256.0 alpha:1.0];

_teacherText.font = [UIFont fontWithName:@"Helvetica-Bold" size:25];

_teacherText.backgroundColor=[UIColor whiteColor];

_teacherText.text=@"Hello World";

[self.view addSubview:_exitButton];


Is there anything I am missing?

You are missing to add line

[self.view addSubview:_teacherText];

instead of

[self.view addSubview:_exitButton];

And Some things I want to correct that :


1. You are asking question about UITextView

2. You are adding UITextField in self.view programatically, right

3. And adding _exitButton in self.view which button I think added from nib (.xib or storyboard)

4. And finding solution for error : No visible @interface for 'UITextField' declares the selector 'removeFromSuperView'


Isn't it something wrong ? Please first clear your requirement and code and correct missing code and try again, I hope it solved your problem.

removeFromSuperView not working with UITextView
 
 
Q