Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPageViewController OR UIScrollView with Paging Enabled = YES

I've gotten a little confused for how I should implement below,

I need to scroll between UIViews or UIViewControllers each one having different set of data do display. For example, 1st view has a UITableView, other only has a button, 3rd may again have a UITableView.

Should I be using UIPageViewController and load different UIViewControllers for each content OR use UIScrollView with contentSize = number of pages.

In my current implementation. I have used UIScrollView which scrolls between different UIViews and loads their content. But, the problem is when I tap on the UITableView in one of the views, tap events are not captured by UITableView, but UIScrollView captures the touch events.

I did try bringing my UITableView to front with,

 myTable.becomeFirstResponder()
 scrollView.bringSubviewToFront(myTable)

 scrollView.delaysContentTouches = false
 scrollView.canCancelContentTouches = false

I added a UITapGestureRecognizer on UITableView but it does not receive tap events. UIScrollView receives a tap event if I add UITapGestureRecognizer on it.

My current view heirarchy is,

UIScrollView -->
              UIView --> 
                       UITableView
              UIView -->
                       UIButton and other subViews
              UIView --> 
                       UITableView

NOTE : I want this scroll view or paging view only as a portion of my main View Controller. (half of my main view)

Please guide me through this.

like image 524
Vish_iOS Avatar asked Nov 13 '15 12:11

Vish_iOS


1 Answers

I found the solution myself,

I just had to remove the UIView from the hierarchy where a UITableView was required. So now my view hierarchy becomes,

UIScrollView -->

          UITableView --> 

          UIView -->
                   UIButton and other subViews
          UITableView --> 
like image 119
Vish_iOS Avatar answered Oct 13 '22 15:10

Vish_iOS