Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overlapping table view scrolls tableView behind it

Tags:

Basically I have a compound view in my storyboard:

  • a UIView with inputs. Let's call it View1
  • container view displays tableView controller (View2)

Works fine.

I have a small issue when another displayed tableview from UIView overlaps the bottom View2 with its own results. Only cells that stays within the bound of the View1 can be interacted with and selected. The part of the tableView (autocomplete results) that actually overlaps View2 (and it looks like it is on top) scrolls the View2..

enter image description here

I already tried referencing View1 and setting View1.layer.zPosition to a higher value. It wouldn't help..

Any suggestions?

If this requires modifying the code Swift syntax is preferred over obj-c

like image 841
kernelpanic Avatar asked Apr 26 '15 07:04

kernelpanic


People also ask

Is Tableview scrollable?

To be precise, table views and collection views are also scroll views. If you look at the documentation of the UITableView class, you will see that it descends from UIScrollView.

How do I scroll to the top of a Tableview table?

To scroll to the top of our tableview we need to create a new IndexPath . This index path has two arguments, row and section . All we want to do is scroll to the top of the table view, therefore we pass 0 for the row argument and 0 for the section argument. UITableView has the scrollToRow method built in.

What is Tableview?

A table view displays a single column of vertically scrolling content, divided into rows and sections. Each row of a table displays a single piece of information related to your app.


1 Answers

Your problem comes from the fact that the tableview with the autocomplete results is added to view1. And so it only receive touches sent to it. If you select clipSubviews on the view1 you'll see that your autocomplete results tableView will be cut to the bounds of the view1 1.

Try to add the autocomplete results tableView to the self.view(main view of the View Controller). This way it will be above both view1 and view2 and it will receive all the touches that come on this tableview

like image 70
pteofil Avatar answered Sep 27 '22 21:09

pteofil