rbertsch8
rbertsch8

Reputation: 222

How to get a subview of a UITableViewCell to extend outside of the cell's bounds

I have a custom UITableViewCell that looks like the following :

cell picture 1

The white textbox here basically functions like google autocomplete. So when the user starts typing something, another tableview extends from the bottom of the textfield with up to 5 autocomplete results.

So I have a tableviewcell that has another tableview within it's content view. The nested tableview has a height of 0 until the user begins searching then it grows to show up to 5 results. I want the nested tableview to be able to grow outside of its parent view, but it is getting clipped.

The tableview with the autocomplete results is being cutoff at the edge of the tableview cell. I've tried settings clips subviews and clips to bounds properties of just about everything to NO and it's still not displaying outside of the cell's content view.

This is what's happening :

cell picture 2

There are 4 more results that I can scroll to after France, but the nested tableview is clearly being cutoff by the next tableview cell below it.

Ive set: tableviewcell's contentview clips subviews to NO, main tableviews clips subviews is set to NO, and the nested tableview's clips to bounds is set to NO.

Is it possible to get this nested tableview to be able to grow outside of its parent view (cell.contentview)?

Upvotes: 1

Views: 2129

Answers (2)

dRAGONAIR
dRAGONAIR

Reputation: 1191

an easier way is add the search result table on the tableview to which the above cell belongs, populate the search table based on the text entered by the user. the origin of this table depends on the textview's cell in which the user is typing.. hide/unhide this search table based on textview didstartediting/end editing..

Upvotes: 0

Ian
Ian

Reputation: 4185

You could make it grow outside the cell's bounds (via clipsToBounds = NO), but the fact that it's outside its superview's bounds will make it impossible for the user to tap any cell.

You could do two things:

  1. Make the cell grow enough so that the user can actually tap the cells inside the table view.
  2. Add the results table view to your view controller's view (ie. where the original table is) and align it to the textfield in the cell. That way it'll be clickable and completely visible.

Upvotes: 2

Related Questions