views:

623

answers:

1

Hello everyone

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];
A: 

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?

Pascal
The tableview can be scrolled by touching inside the textfield and dragging up or down. This should mean that the contentsize is big enough to encompass the textview, right?
MW
Hmmm, I'd say so. Strange, I just copied your code into one of my projects and it worked as it should, displayed a text input field and the keyboard slided up on touch.
Pascal
Thanks for taking the time to look into this. I have since decided to structure my UI differently, to avoid this problem.
MW