Swipe-to-Delete on rightest UITableViewController inside UIPageViewController - uitableview

Looks like UIPageViewController prevent UITableView to get touch events. My table view is placed in rightest page, so there is no potential problem to recognize gesture.
Is there any solutions of this problem?

Put this in your UIPageViewController's viewDidLoad function.
if let myView = view?.subviews.first as? UIScrollView {
myView.canCancelContentTouches = false
}

You can use this third party library which will allow the swipe gesture of the menu to have president over the uipageviewcontroller swipe
https://github.com/WinterKirk/MKSlidingTableViewCell
the important thing is that your whole view shouldnt only have these kind of cells cause then the uipageviewcontroller wont be able to swipe
but it works great in situations where you lets say have an image and comments under it and people should be able to delete the comments but swipe to the next pic on all other cells

Related

Swift canEditRowAtIndexPath not working in UIPageViewController EZSwipeViewController

I have the following scenario and need help in resolving a tricky situation in the scenario
There is an Xcode project and am using EzSwipeController for swipe (pagination effect) between three View Controllers at the moment.
In my first ViewController (this viewController is fetched from my custom dynamic framework as part of my requirement) -
Code to fetch ViewController:
userProfile.createProfileUI(userSession!) { result in
switch result {
case let .Success(profileViewController):
myDetailsVC = profileViewController //myDetailsVc is passed to EZSwipControllerDataSource array
default:
break
}
}
The other two ViewControllers are within my project storyboard
The Problem -
In the first ViewController, there is a tableView with canEditRowAtIndexPath enabled for few cells (phone numbers).
So when I try to swipe the row, the EZSwipeController responds first and
hence, I am not able to edit the row.
Here is what is happening - http://recordit.co/SOJgdeYchP
Here is what should happen - http://recordit.co/EBPSbjH31q
How do I handle this problem? Is there a way where I can override the default swipe controller action when I try to edit the row?
Please help!
Attach the swipe gesture recognizer to a parent in the hierarchy.
If you're using a UITableViewController, replace it with a UIViewController with a UITableView inside it. Then just drag the gesture recognizer onto the view controller in Storyboard, and it'll attach to the UIViewController's Content View instead of the UITableView.
Though at the end of the day, this is inherently a flawed approach, since swiping to flip pages in an app is only ever viable if you don't have any elements on the pages that also have swipe gestures in them. If you do, even if you code a workaround to make the gesture recognizer for the element in the view controller (in this case, a table view cell) fire instead of the page flipping swipe gesture, that creates an inconsistent user experience.
My suggestion: don't use a table view for such a form altogether. On top of the aforementioned mechanical UX issue, from a user perception perspective, there's nothing indicating visually that this is a table view and not just a scroll view, so there's nothing indicating to the user that swipe actions (Delete) are available. Use a scroll view instead, and take a different approach to deleting (Delete buttons that are always visible, Delete buttons that are only visible after the user hits Edit somewhere, etc.).

UITableView inside a UIScrollView not responding to swipe events

My question is similar to a bunch of questions on stackoverflow (eg. swipe to delete in a UITableView which is embeded in a UIScrollView)
I need to implement a swipe action on a table view cell for a tableview controller which is a custom view embedded in a scrollview. However, the swipe events are not working properly and I understand the problem is that the UIScrollView is eating up the events for the UITableView so I tried out a bunch of options.
1) I subclassed the UIScrollView with the touchesBegan, touchesEnd etc methods but they never seem to get hit.
2) I could get hits on scrollViewWillBeginDragging but I am not sure how to call the responder for the UITableViewController from this.
3) I implemented a gesture recognizer in the tableviewcontroller class but that also didn't help.
I am confused as to how to go about so some code in Swift 3 syntax would be really helpful.

How to make a switch from one view to the same view?

I'm creating a questionnaire app for iOS in Swift.
I only need one view for all questions. How do I make one generic view and make it look like I'm switching to the new view with swipe when only replacing some of the data on that view?
Alright, so I think I know what you're attempting to do. You could possibly do it like this. This is assuming you have a custom UIViewController subclass with all your textfields and labels on it; I've named this QuestionaireViewController.
let nextVC = QuestionaireViewController()
self.navigationController?.pushViewController(nextVC, animated: true)
Additionally, you'll want to set up unwind segues each time you create a new VC, so that if needed the Navigation Controller can segue back.
You can add an animation to your subviews (UILabels, etc.) on screen. You can add a separate animation to each swipe gesture and have the animation move in the direction of the swipe. I like this because you have some flexibility in what you animate and how you do so.
You'll need to setup swipe gesture recognizers and methods for each to handle the swipe and animate the layers.
If you want a "traditional feeling" swipe left / swipe right type of setup you'll need to setup a push animation with a subtype for each direction.

Swipe between views

I have two views in a single XIB and I want to be able to swipe between them. I've looked at other tutorials but the swipe isn't right. I want the swipe to be the kind of swipe you get on the Photos app. For example, the views appear from the direction of the swipe, able to hold it in the middle and let it snap to the closest view, etc.
I am not using storyboards.
You can use a UIScrollView which contains the ViewControllers: Have a look at this post:
How do I put viewController's into a UIScrollView
What you are looking for is a stacked view controller -- similar to the Facebook app. There are plenty of frameworks out there to do this. Here are a couple of good examples:
https://github.com/steipete/PSStackedView
https://github.com/raweng/stack-scroll-view

xcode - pageviewcontroller override gestureRecognizers

I have used page-based application example shipped with xcode to build my app. The page view controller works fine, however, I have such problem:
In each view controller representing page data, I have some buttons, and clicking it leads to another view controller's view. I use this to add the view to view hierachy:
[self.view addSubview: self.articleViewController.view];
articleViewController just has a scrollview inside and show some text data. The problem is, if I swipe the view to scroll up/down, when it reaches the end page view controller takes this gesture and move to previous/next page, which not what I want. I want articleViewController receives no gestures from page view controller but only scrolling itself.
Hopefully I described good enough..
How can I disable gestures in my articleViewController? I have tried to study this post: UIPageViewController Gesture recognizers but haven't figured it out to solve my problem.
An example project to illustrate the problem: https://dl.dropbox.com/u/43017476/PageTest.zip
I know you cited the same question, but I don't like the accepted answer. Check out this answer, which is a bit further down the same post. I had the same issue and adding the block of code from that answer to the end of my viewDidLoad in my UIPageViewController fixed the issue I was having.
Basically what's happening is that the UIPageViewController is consuming all of the touch events, so you need to remove certain UIGestureRecognizers from the UIPageViewController so that it doesn't respond to those. It might be a little trickier than the example I posted as that is just removing UITapGestureRecognizer, but it's the same basic concept. You need to make sure that the UIPageViewController only advances to the next page on a right->left swipe gesture, and not an up->down swipe gesture.
Check out the UISwipeGestureRecognizerDirection documentation.

Resources