I actually just posted, but I am re-asking to give a better concept.
I'm trying to use a segmented control change through multiple views inside a container view. I'm also not sure how to embed multiple views inside the container view. I saw a tutorial how to do it in Objective-C, but I am coding in Swift.
This is a perfect example of what I'm looking for. There is a UITabBarController on the bottom, but there is a segmented control to alter between "Tweets" "Photos" and "Favorites." How could I achieve this?
Thanks in advance!!
I'm assuming you have a collection view or table view or something below the segmented control. If that's the case, I've had good luck using the segmented control to switch data sources (and delegates, if necessary) for the collection. If you just have views, you can use the segmented control to show one and hide the others.
Do you have any code or more specific questions?
Related
I would like to implement something like below:
But, I would like to have my first version app without the map, later on, I will add the map. So, the eventual goal is to show both map and the other things showing on above screen.
My question is, how to make it happen? It sounds like I should have the map and the rest UI in two files (xib or storyboard) respectively, then later on, combine them together. But I am not sure what is the right way to implement these things in iOS?
Can I implement a view component which only contains map, then, another view component only contains the rest, then later on, combine them & one UIViewController associate with the combined view? If so, how to do it? If not, what is the correct way to achieve this?
I think you can achieve that by using container views; add 2 container views to your view controller in your Storyboard, the upper container view will contain the map and its stuff, and the bottom one will contain anything else.
To hide the first container view in your first version of the app you'll only need to set the height constraint of the upper container view to 0 after setting the other constraints properly.
If you wanted to use a view controller from another Storyboard file, you can check my answer here.
I have a view with two child views, and want the second view optionally to disappear, that is disabled including the dataBinding, and resize the first view, and vice versa. I need some hints or (pseudo) code how to accomplish this. Thx in advance.
There are quite a few views in SproutCore which do this in some way or another. While it is not the best example, have a look at the experimental select search view.
You are going to need to override createChildViews to set up the bindings manually, so you can also take them down when required.
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.
I would like to use Pager Sliding TabStrip in my project.Pager Sliding Tapstrip is there for android. Can we define like this? I have taken one scroll view, added subviews on it for tables and take one uivew, added buttons as subviews and added uilabel as subview for tabstrip . While using the scrollview means dragging the scrollview, the tabsrip has to be moved.I have been stuck to this concept and i am not getting any idea to solve this issue. How do i get this concept? Please give any idea to me anyone.
Can't you use UIPageControl for this ?
From Apple example:
https://developer.apple.com/library/ios/samplecode/PageControl/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007795
And to have a custom UIPageControl, like this https://github.com/Spaceman-Labs/SMPageControl .
You can try UIPageViewController to manage your tabs.
I'm not sure how many tabs do you have. If you have many tabs and you add all tables into the scrollView at the beginning time, the performance and memory usage would be really bad.
So you'd better reuse controller and views for your tabs. If you use UIScrollView and manage them by yourself, what you can do is calculate current page according to the contentOffset, and load the current page, previous page and next page. Because three pages is enough to cover what user will see. However the better solution is using UIPageViewController, it will deal with contentOffset and pagination, what your need to do is just provide previous controller and next controller according to current controller. Then update your tab view according to current controller.
EDIT:
BTW, if by "the tabstrip has to be moved" you mean when you drag the scrollView, your tabstrip moves as well, that's because you added your tabstrip to the scrollView. What you need to do is add it to the root view, and the scrollView and the tabstrip should be siblings rather than parent and child.
I am developing application which required same features as asked by you.
I am using SHViewPageController. You can find it from following link.
https://www.cocoacontrols.com/controls/shviewpagerexample
I hope it will help you. Thanks.
This may help you....
you can change the tab at top or bottom. also it has got some nice customizations
https://github.com/iltercengiz/ICViewPager
I have noticed the UI Component in XCode: Container View.
Based on the description provided I would like to make use of it to display a reusable component of my app in several different screens. I have been looking around online to try and find a basic tutorial or some documentation on it, however I havent found anything of use.
Please could someone advise on how to wire this up and make use of it? At the moment it also appears that the container view doesn't seem to resize which is problematic. Any tips on how to enable this would be appreciated too.
Cheers.
Well let's break this into some simple steps:
Drag a container view to the main view of one of your controllers. When you drag the container view, IB will create an embed segue for you and you can resize the container's view by dragging the resize control points as usual. Any changes in the size will be automatically reflected to the view that the segue is pointing to. The idea is that this view will be managed by a different controller, the embedded one.
Set your custom subclass as the class of the embedded controller.
Now you're good to go. Note that any containers you add will be available through the childViewControllers property on your main controller.
This is obviously an oversimplified workflow but it's enough to get you started. For more information on the subject, see Apple's documentation here.