R – Placing UITextView inside a UITableView footer

iphoneuiscrollviewuitableviewuitextview

I have a UITableView with footer view. This footer view contains a UITextView as a subview. Both the table view and footer view are created programmatically. The text view appears on screen correctly, but it doesn't display any text, nor does it respond to touch events.

Could the problem be related to the fact that UITextView is a subclass of UIScrollView? Or have I just missed something in my initialization of the text view?

The code where i initialize the footer and text view looks like this:

// Create the footer
UIView *tempFooter = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
[tempFooter setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[tempFooter setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
self.tableFooterView = tempFooter;
[tempFooter release];

UITextView *tempTextView = [[UITextView alloc] initWithFrame:CGRectMake(5, 5, 270, 140)];
[tempTextView setDelegate:self];
[tempTextView setEditable:YES];
tempTextView.keyboardType = UIKeyboardTypeDefault;
tempTextView.returnKeyType = UIReturnKeyDone;
self.textView = tempTextView;
[tempTextView release];

[self.tableFooterView addSubView:self.textView];

Best Answer

I bumped into a similar problem lately and discovered that the contentSize of the superview (A UIScrollView) of some input elements was too small. Content would display (clipsToBounds = NO), but touches would not be detected.

Did you check whether your actual table is high enough to also accomodate its footer view?