I need some help. I have a UITableView with custom UITableViewCell. In the Cell I have one UITextView. I need to do, when the user will type some data into UITextView. UITextView will resize from content of UITextView. I realize it in - (void)textViewDidChange:(UITextView *)textView But now I need to resize the cell also, if content size of UITextView will bigger then the current Cell.
The question is how to resize UITableView Cell by UITextView contents size.
My code bellow.
@class TableCell;
@interface RootViewController : UITableViewController{
UITableView*tableViewTest;
TableCell *tableCell;
}
@property (nonatomic,retain)IBOutlet TableCell *tableCell;
@property (nonatomic,retain)IBOutlet UITableView*tableViewTest;
@end
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
TableCell *cell = (TableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"TableCell" owner:self options:nil];
cell=tableCell;
self.tableCell=nil;
}
[cell setTag:indexPath.row+1];
return cell;
}
- (void)textViewDidChange:(UITextView *)textView
{
CGRect frame = textView.frame;
frame.size.height = textView.contentSize.height;
textView.frame = frame;
NSLog(@"Change=%f",textView.contentSize.height);
}
@interface TableCell : UITableViewCell <UITextViewDelegate>{
UITextView *textViewTest;
}
@property (nonatomic,retain) IBOutlet UITextView *textViewTest;
Thanks for help