Swipe between UISegmentedControl to view different Collection Views - ios

What is the best possible way to swipe left and right to toggle between two segments in a segmented view, and show different content for each segment selected. The content I want to show for each segment is a collection view of images. So segment "public" shows one collection view, and "friends" shows another.
I am not sure if I should use UIScrollView or use a UIPageViewController or if there is another option. This is close to what I want but it is in objective-c and I am looking for a much simpler solution in swift. github example

Use swipe gesture to got this.
And keep trak of currently showing VC. change as per you require.
Use this link for swipe gesture.

Related

How to navigate between different parts of an app within only a part of the screen?

After a few hours of research I couldn’t find anything related to this question.
This is what I am trying to achieve.(demo made with flinto)
My Objective
The bottom half of the screen has a view with 3 buttons on the top represented by shapes . Beneath the buttons are collectionViews (with stripes) and further down is a view at the bottom.
Every time a different shape button is clicked I need the view to be modified such that the bottom bar View appears static while the collection views change. The first (triangular) shape button also has sub buttons (represented by Aa , Bb and Cc) that can further cause the collection views to change.
Question
So my question is how can I go about this ? Shall clicking each shape button present separate View controllers or can I achieve this within only one view controller where the bottom view is modified every time I click a button.If so how?
I simply need you to point me in the right direction and I could really use some links to useful tutorials . Thanks!
.
Have you tried using segmented control?
Segmented control gives you the option to change the UI based on which segment is selected:
#IBAction func indexChanged(_ sender: AnyObject) {
switch segmentedControl.selectedSegmentIndex
{
// based on which shape is selected, you can hide/show/change color of other components here
case 0:
// triangle is selected
case 1:
// hexagon is selected
case 2:
//circle is selected
default:
break
}
}
The way I would go about this is to use only one view controller, put a stack view inside, and insert multiple segmented control inside the stack view, then manipulate them using the logic above.
Note that if you want to customize the looks of your segmented control, I would create my own subclass of UISegmentedControl where I would configure the UI.
This is what depends on what kind of functionality you want to implement in your app. Now lets be the short and sweet suppose you want only change the collectionview by the clicking each shape you can achieve it with custom tabbar view using simple UIView on single viewController. And if you want your app by adding service call and other UI elements like UITableView and many others at that time I recommended you to go with default UITabbar.

How to create a tab control in iOS similar to Windows Forms?

I am looking to create a tabcontrol similar to the one present in Windows Forms.
Here is an image of what I am looking to achieve:
What I have in mind to creating this is having buttons at the top and clicking those buttons would hide or show Views depending on which button is clicked.
Is there an easier way to create this component or is this the only way?
You can use either a UITabBarController (Bottom) or you can use a UISegmentedControl. And handle each time you select a UISegmentedControl item, you change a ContainerView (Which will act as the pin/window).
Of course, you will have to play with .isHidden true and false.
Another option is, instead of using a Container View, using a horizontal Collection View with scrolling disabled. And when you select a UISegmentedControlItem, you scroll programmatically to the other item. Each CollectionView item would act as the pin/windows.
If you are not comfortable with any of these options, you can look for a third-party library. For example https://github.com/xmartlabs/XLPagerTabStrip
Look up the UITabBarController. It sounds like a fit for the job.

Putting Text into horizontally UIScrollView and appropriate AutoLayout - Swift

So I want to create a Slider on the top of the UI, each item representing a Category (there will be five items). I don't want to switch to another Controller, when sliding to another Category, I just want to load new data into the current controller. So I guess the UIScrollView is the way to go.
See here for what I want to realize:
I have trouble now to show the name of the chosen Category in the middle of the Slider, and by the same time on the left and right its neighbors.
Using a effective AutoLayout is a also necessary.
Is putting Panels into the UIScrollView the right way?
I am new to iOS-Development and would appreciate any help.
Add a scrollview to the top of your controller, in code configure scrollcontentwidth to screenWidth*5 and on each swipe change reload the data of your controller.

UITableView inside of UIScrollView or using TableView Header

I guess this question is more of a best practice question than a problem solving question.
I would like to have a page on my app that has a UITableView at the bottom of it and some buttons/text above the UITableView but instead of just the UITableView scrolling, I would like the whole page to scroll.
I have been searching around and some people say to put the UITableView inside of a UIScrollView and disable scrolling on it and recalculate the height so the table view is as tall as all of it's rows.
Then I have read some other people say just to put the buttons/text in a Table Row Header and just have that scroll with the whole table view.
Which is the better practice and are either of them frowned upon?
Thanks!
Open the main storyboard and on the bottom right hand side you should see a list of view controllers, buttons, gestures etc.. In that list there should be a controller called "page control" that opts for the page-scroll you are looking for as well as the continuous one which you are trying to get rid of, you can just insertt this in to your basic view controller (via drag and drop). As for the button responsible for the segue (turning the page) you can find that in the list too. I can't explain how to program the button to turn the page step by step as I am typing this on my phone at work right now. If you want I can edit this later in more detail

Need Suggestion to Swipe through Views

I have a UITableView on didSelectrowAtIndex it pushes to a viewController which shows the detail on UIScrollView which is vertically scrollable.
Now I need that If I tap on any row it would be pushed to the same viewController and shows the detail of selected row,Additionally I need to have the Swipe Functionality to see the data for all rows in tableview instead of go back & select another row.
I know it can be achieved by UIPageControl or [scrollView setPagingEnabled:YES];,But I am wondering If there is any better approach to do the same or I should go with any of these two,If yes then Which one is better?
Please Help Guys.....Any Help would be much appreciated.
Thanks in Advance....:)
Of course, there are plenty of approaches to achieve what you want. You should keep in mind that UIPageControl has limitation on number of items (dots) displayed (over 20 items would overlap). Also, it would be appropriate to have next/previous buttons for the users preferring tapping buttons instead of swiping/panning. I prefer using UISwipeGestureRecognizers and buttons on toolbar for navigating between items.
The key, in my opinion, is to control how many UIKit controls are held in memory at the same time. However you implement this, you want to make sure that you have solution that holds UIKit controls for the currently visible child element only, or perhaps the previous and next ones, too, but not for the full array (especially if you're dealing with UIImageView objects).
One control to consider is UIPageViewController. At first blush, it might look complicated, but in reality it's quite simple and offers a nice way to swipe between various "pages" while not holding all of the pages in memory at the same time. See View Controller Catalog for iOS: Page View Controller.
If you decide to implement a scroll view with paging enabled, I'd suggest specifying the delegate and implementing the UIScrollViewDelegate methods to add and remove subviews as appropriate. This is historically what I've done, but I now lean towards page view controllers.
There are also a ton of third-party implementation of "infinite scrollers", which implement this sort of functionality, though I can't vouch for any particular one.

Resources