Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have created one demo for your problem, hope will help you.</p> <p>My idea of solution is using <code>AutoResizingMask</code> of <code>UITextView</code>.</p> <p>My .h file</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface ViewController : UIViewController&lt;UITabBarDelegate, UITableViewDataSource, UITextViewDelegate&gt;{ IBOutlet UITableView *tlbView; float height; } @end </code></pre> <p>And my .m file (Includes only required methods)</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. height = 44.0; } - (void)textViewDidChange:(UITextView *)textView{ [tlbView beginUpdates]; height = textView.contentSize.height; [tlbView endUpdates]; } #pragma mark - TableView datasource &amp; delegates - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 1; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.row==0) { if (height&gt;44.0) { return height + 4.0; } } return 44.0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CellIdentifier"]; UITextView *txtView = [[UITextView alloc] initWithFrame:CGRectMake(0.0, 2.0, 320.0, 40.0)]; [txtView setDelegate:self]; [txtView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; // It will automatically resize TextView as cell resizes. txtView.backgroundColor = [UIColor yellowColor]; // Just because it is my favourite [cell.contentView addSubview:txtView]; return cell; } </code></pre> <p>Hope it will help you out.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload