0

I have a custom UIView and .xib called ViewA, ViewA has a fixed height of 60pts. ViewA has a subview named ViewB (which has its own .xib) which contains a UITableView. ViewB is initially hidden and has a height of 400pts (much bigger than the height of ViewA). ViewA also has button which shows and hides ViewB. ViewBs X and Y coordinates are 0,0 to that of ViewA, ViewB also has the same width as ViewA. When pressing ViewAs button to reveal ViewB it is shown correctly - ViewB extends outside of ViewAs bounds. However, I can only scroll ViewBs UITableView within the first 60pts (the bounds of ViewA) the rest of the extended view does not scroll.

I have tried using hitTest answers found here but I cannot seem to get it to work.

The desired effect is that ViewA will display ViewB which should have its full interaction and act as normal. ViewB should also overlap any other views that may be in a UIViewController. It works fine apart from the UITableView in ViewB not being fully scrollable ie. scrolling from the row at index 0 scrolls the table fine, but there is no scrolling from `index 5`` for example.

Any help would be greatly appreciated?

Some more info:

  • Autolayout is being used in the storyboard
  • ViewBs zPosition is 1
  • the desired effect is similar to date of a DropDown menu.
  • I dont want to use a third party library

Thanks in advance.

DevC
  • 6,982
  • 9
  • 45
  • 80
  • Set .clipsToBounds = true` on ViewA and you'll see why you can't scroll. You need to change the height of ViewA to match the height of ViewB. – DonMag Nov 16 '18 at 18:28
  • @DonMag ya I did that thanks. I tried adjusting the height also, when ViewB is being presented I set ViewA to have the same height as it. ViewB was still unscrollabe. But when I dismissed ViewB, ViewA was the new height that I set. However I did notice that the button I was using to reveal ViewB was only clickable within its original height also, not the new one – DevC Nov 16 '18 at 19:07
  • Hmmm... still sounds like a bounds issue. Is ViewA *also* contained in another, shorter view? – DonMag Nov 16 '18 at 19:33
  • @DonMag ViewA is just in a ViewController. It’s possible that’s something else is going on with my .xib maybe – DevC Nov 16 '18 at 19:35
  • To debug... set all related views to `Clip to Bounds`, and give each one a different background color. That often makes it much easier to see what's going on at run-time. Also, use Debug View Hierarchy to check the views. – DonMag Nov 16 '18 at 20:12

0 Answers0