vicky
vicky

Reputation: 253

How To Fix UITextView in storyboard TextView

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

Answers (3)

UdayM
UdayM

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

Rohit Khandelwal
Rohit Khandelwal

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

PinkeshGjr
PinkeshGjr

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

Related Questions