Swipe to the same Viewcontroller - ios

I am trying to implement a left-right swipe gesture to navigate between an array of objects, that i can change the properties and take actions. The navigation is more of a previous-next approach. I have a table view that segues to this Viewcontroller, and i would like the user to check the next object without getting back to the TableViewcontroller. What is the best approach to implement this?
I know PageController isn't ideal in my situation as i'm not navigating between different VCs.

A page view controller is the best way. Make the views view controllers instead. It does all the work for you.
Failing that you could use a collection view with a custom flow layout.
Failing that, you could roll your own custom view controller that implemented this feature.
EDIT:
Based on your screenshot, where you say "swipe back and forth to move between rows of a table view" you need a collection view. Table views scroll up and down between rows. That's what they are made to do, and trying to implement a swipe interface to instead scroll side-to-side is crazy. Simply use a collection view configured for horizontal scrolling between cells.

Related

how to manage view controllers in a sequential pattern - swift

I'm trying to implement sth like images below. there are some views that should be displayed in a sequential order and a bar above them shows the flow of tasks.
as it is shown, first profile view should be displayed. when the user clicks on Go to Next View Button second view (price view) should be displayed. the top bar shows the current view where we are in it. I've tried PagingMenuController already to create a menu with views and then disable scrolling. but PagingMenuController loads all views at the same time and also i don't know how to go to next menu item within child views. now I'm thinking of a container view might be helpful but i didn't use container view so far and i don't know it's good for my purpose or not.
also i want that top bar without swiping between views (only on buttons) and one enable view at the same time.
any helps would be apprectiated.
Your question is both broad and vague. My answer is also going to be fairly high level. I suggest you follow my outline, and if you get stuck on a particular step, post your code, tell us about the problem you're having, and we can help you fix it.
This is pretty simple. Create custom view controller. Give it a container view at the bottom that would contain the current child view controller. Use view controller transition methods to switch between child view controllers. You'll want to add layout anchors to each new child view controllers to pin all of it's view's edges to the edges of the container view.
Create a custom control on top to show the dot and highlight the title of the current view controller.
If you want the next/previous buttons to be on the child view controllers, put them there, and add a delegate property to all the child view controllers that points to the parent view controller, with next and previous methods.
BTW, in languages, like English, where text is laid out from left to right, I would think your first page would be on the left and the last page would be on the right. (I think it makes more sense for profile to be on the left and pay on the right.)

Prefer swipe to delete over a competing swipe gesture

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.

Detect swipe events on UIPageView below UITableView

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.

Scrolling view controller with Navigation Bar

I have a view controller with lot of data under a navigation bar.
I want to make a transition to other view controller which looks like I'm scrolling them.
My idea is to have 3 elements at the same time and charge them into a scroll view and when I scroll to other view controller release one of them and charge another view controller to have 3 every time.
Somebody know an easier way?
Thank you all for your time.
If you only have 3 elements, then use a single UIViewController with a scroll view that contains the 3 different element UIViews. If you are looking to scroll through a larger set of data and want to view only 3 elements at a time, then go to a UITableViewController and implement your views as UITableViewCells.

Designing view on top of multiple embed views

I have the task to design a application that has a main view which is always visible (it has a button on it's bottom side, and when pressed a image displays on top of all views), and a set of TableControllerView's that should appear under it, and the user needs to be able to navigate through them.
I know that you can embed a view inside another, but you cannot refer more than one view to it. The current way I'm trying to do now load one TableViewController inside the embed view, and when the user clicks the cell I manually load the other controller and add it as a child of the main view, which is the RootViewController. The problem with this approach is that the navigation bar gets stuck using the root view controller, so I have to manipulate the main navigation items on each subview transition, and second is that the frame for the second view I load is coming as it had full size, making some cells be under the main view button. This way doesn't uses segues for transition, so it makes the storyboard kinda useless.
I was thinking into using a TabViewController with it's tab hidden, but wanted to ask here for a better solution.
As you discovered, a TableViewController likes to fill up the whole screen (except navigation bars, tab bars, status bar, etc. which are official Cocoa Touch GUIs). When you want a table view to fill only part of the screen, you are supposed to use a UITableView but not a UITableViewController. You set your custom view controller object (subclass of UIViewController, not UITableViewController) as the table view delegate and data source. You will need to duplicate part of the functionality of UITableViewController in your custom view controller, but it's not a lot more than you have to do already to supply the data.
You should probably follow the standard design pattern and have separate view controller objects for each of the "pages" the user can navigate to. You just have a main button and image on each of them. But I could imagine why that might not give you exactly the effect you want.

Resources