Reputation: 253
Here i want to fix a UITextView which i created programatically in textView added on storyboard. I have tried it this way but not working.
_textView is a textView in which i have to fix UITextView *descrip
contentView is the view on which i have _textView.
UITextView *descrip = [[UITextView alloc]init];
descrip.view.frame = CGRectMake(_textView.frame.origin.x,_textView.frame.origin.y,_textView.frame.size.width,_textView.frame.size.height);
[self.contentView addSubview:descrip.view];
Upvotes: 0
Views: 227
Reputation: 1783
If I understood correctly, you are trying to add descrip into_textView; try this:
UITextView *descrip =[[UITextView alloc]initWithFrame:CGRectMake(0, 0, _textView.frame.size.width, _textView.frame.size.height)];
descrip.backgroundColor=[UIColor blueColor];
[self.contentView addSubview:descrip]; //here add subview to texview not content view
Upvotes: 0
Reputation: 1778
You can do something like this--
UITextView *descrip = [[UITextView alloc]initWithFrame:_textView.frame];
[self.contentView addSubview:descrip];
there is no need to to use CGRectMake
if you want to give same frame as _textView
frame
.
Upvotes: 1
Reputation: 8680
here is proper method
UITextView *descrip = [[UITextView alloc]initWithframe:CGRectMake(_textView.frame.origin.x,_textView.frame.origin.y,_textView.frame.size.width,_textView.frame.size.height)]
[self.contentView addSubview:descrip];
Upvotes: 0