I'd like to give a go at implementing the same functionality of Snapchat specific to the way you get into a text chat with a friend in that app.
I have three view controllers in a UIPageViewController. The middle view controller is a UITableViewController with an expandable cell and five subcells that appear when the cell is expanded. I have a UIPanGestureRecognizer in each of the subcells where as you slide to the left on a cell, a button is revealed. However, both the pan gesture recognizer and the UIPageController sliding to another view controller are happening at the same time. How do I disable the UIPageViewController sliding until a user is sliding the UITableViewCell?
I'd like to have it just like Snapchat by doing the following:
Disable the UIPageViewController sliding. Then, as a user is sliding a UITableViewCell with the UIPanGestureRecognizer, when the button is fully revealed, THEN switch the UIPageViewController sliding back ON so when the user slides further, it starts to slide to the next view controller.
I think that I'll have to put some of this in the CustomTableViewCellDelegate of my CustomTableViewCell. Any ideas on how to implement this? I can email my Xcode project to recreate the problem if need be. Thanks.
EDIT: Finally learned how to upload my Xcode Project to GitHub. My project can be found on this link https://github.com/cnowak7/PanGestureTest to recreate the problem.
Related
I am developing Sliding tab layout with the help of Swift 1.2. Sliding tab must have single UITableView.
UITableView will be refresh when I slide / move the tab.
I have tried many tutorials from other sources, but could not get proper hint as most of tutorial used separate ViewControllers for each tab. What i want is, to use single ViewController with one UITableView for all tabs.
How to achieve this in iOS - Swift?
Implement a pan gesture recognizer on your tab view, track the movement to next tab on that view. When it does, reload your tableview's data.
So I have a tableViewController inside a XLPagerTabStrip view controller, basically a pod which allows me to swipe between child view controllers left and right. The problem is that I want to disable the view controller scroll when the user swipes on a cell on my tableView. In this case I want him to be able to see the delete option, instead of changing the viewController itself. Is this possible? Currently, I see the delete button only if I swipe really, really fast and in all other scenarios, the entire viewController is swiped away.
I don't believe there is any sort of preference property for UIGestures. Instead, I believe the rule is the first gesture added takes precedent. However, in your specific circumstance with XLPagerTabStrip, you can simply disable scrolling in the interface builder for your 'containerView' (subclass of UIScrollView). That solved the problem for me anyway, having my children view controllers' UITableViews actions appearing correctly.
So my problem is the following:
I have a UIViewController, in it I have defined a UIPageViewController and added its view to the hierarchy and on top of that I have added an UITableView.
What I would like is to be able to scroll my UITableView (that part works) but also to be able to swipe to change the slides of my UIPageViewController.
My problem is that the UIPageViewController doesn't detect the swipe gesture at all. If I remove the UITableView it works all right of course.
My question is the following: is there any way to pass the swipe events from the UITableView to the UIPageViewController so both would receive their intended gestures ?
You would need to have the tableView inside your page view (in the content view controller for a specific page).
If you have two views on top of each other the front one will intercept all the touches and no actions will make it through to the lower views.
Try setting user interaction on the tableView to false to see what I am talking about. Of course this will cause the tableView to become unresponsive. You will need to implement this a different way.
I'm currently using ECSlidingViewController in my app. As default behaviour, it's possible to show the side menu (MenuViewController or underRightViewController) panning on the top view or calling the RevealMenu: method.
I extended this functionality giving the user the possibility to pan the top view controller back adding this line to the UnderLeftViewController ViewDidLoad method:
self.slidingViewController.shouldAllowUserInteractionsWhenAnchored = YES;
(source here)
Here the limitations:
User must touch the top view on the side to pan it back,touching the MenuController cell won't have any effect. If you look at the Facebook iOS you will notice it's possible to pan the top view starting the gesture in the middle of the side tableviews.
adding the above line of code will disable the TapRecogniser previously active on the top view (and I would need it to work at the same time of the Pan recogniser).
Does anybody know how to implement this behavior?
Ok, I might have found a work around for the tap recogniser problem, instead of the previous line insert this one in your side menu view controller
self.slidingViewController.shouldAddPanGestureRecognizerToTopViewSnapshot = YES;
still it's not possible to swipe on the menu view though,but at least I have swipe and tap events working on the top view once is on the side.
I'm trying to emulate the sliding UIViewController as seen in the Readability app. You can drag a page to the right and it pops the current view off the stack to go back to parent UIViewController with a sliding animation as in the image: the right-most view was on the top and is being dragged right-wards showing the original table on the left.
I've tried a few of the slidingUIViewController solutions such as ECSlidingViewController but they try to emulate the Facebook/Path behaviour of partially sliding a slidingUIViewController on top of another which is not what Readability does.
I've also tried a standard horizontally scrolling UIScrollView but scrolls like the pages are joined at the sides, as opposed to sliding one view over another.
Does anyone know how they did this?
This can be easily accomplished in few steps. I'm not going to write down all the code you need to write in order to do it, but just the steps you need to take. I will use a master-details terminology where the master view is the one from which you want to present a details view and the details view is of course the one at the top of the navigation stack.
When you want to present the detail view:
1) create an instance of the UIViewController that handles the interactions with the detailView. On iOS 5+ you can store this instance in the childrenViewControllers #property on the master's viewController. If you support a lower OS you should store the instance in an ivar.
2) set the detailView's frame to be outside the screen's bounds; add to detailView a shadow for graphical purposes. Finally add the detailView as a subview of the masterView.
3) (optional) add a pan gesture recognizer to the detailView in order to allow the user to swipe the view back and dismiss it.
4) animate the detailView in the screen's bounds. Make sure the interactions with the view below are disabled (be careful not to disable also the interactions with the detailsView!)
When you want to dismiss the detail view:
1) animate the detailView outside the screen's bounds.
2) remove it from it's superview and delete the reference to it's viewController.
3) re-enable the user interaction with the master view.