1

I would like to develop two screens with UITableView and switch between them using swipe and UISegmentedControl. I found on net that for swiping is possible to use UIScrollView with paging. But I found that it is not good idea to add UITableView into UIScrollView also here:

UITableView inside UIScrollView not receiving first tap after scrollling

Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.

I found that in ios is almost exactly the same what I need in notification center. There is possible to scroll vertically and swipe horizontally also. Any idea how can I do similar function?

Thanks! Michal

enter image description here

notification center 1

Community
  • 1
  • 1
kolisko
  • 1,548
  • 3
  • 17
  • 22

1 Answers1

1

You could simply add a UIPanGestureRecognizer to catch the swipes left and right and switch tabs and disable the scrolling in the scroll view you use for switching tabs.

The reason it's not good to put a table view in a scroll view is because the scrolling will interfere. If you disable the scrolling on one it should be just fine.

Rick
  • 3,240
  • 2
  • 29
  • 53
  • I think I need something little different than only recognize left/right swipe gesture and than change segment index. I would like the swipe by catching the screen and move it to left or right as you move finger. And when release the finger it will finish the swipe (paging in scroll view) or swipe back to origin screen which depends on distance your finger swipe. Is possible to do it by UIPanGestureRecognizer? Do you have any example in swift? Sorry for my maybe stupid question but I am newbie to native ios development. – kolisko Dec 05 '14 at 08:01
  • I think the reason Apple didn't do it that way is just what you said in your question, it might interfere with the `UITableView` – Rick Dec 05 '14 at 08:02
  • I think Apple do that. Similar concept is in mailbox and safari. You can do scroll up/down and you can swipe to go to the prev/next page. – kolisko Dec 05 '14 at 08:13
  • I'm not sure what you're referring to in Mail but Safari the navigation behaviour is the same as the one `UINavigationController` provides. This only triggers if you swipe along the edges. Of course you could implement something similar using percent driven animations. – Rick Dec 05 '14 at 08:17
  • yes, you are right, it is only along the edges. Thanks! – kolisko Dec 05 '14 at 08:38