Navigation through the SegmentedControll (AutoLayout) - ios

Good day!
How to arrange elements in ViewController so that when you switch SegmentedControll changed the contents of the second bottom half?
How to implement this with autolayout?
Thank you!
Ps. Very similar interface with Instagram (the first and second tabs). The Android turned out using TabHost, and there really tight... Or maybe this differently implemented and easier?

If you want to use a UISegmentedControl, you will have to manually manage switching the view controllers yourself.
You should take a look at these github projects, they provide view controller management coupled with a UISegmentedControl:
SNFSegmentedViewController
SDCSegmentedViewController
The other option is to use a UITabBarController instead. If you want a different look than what is provided by the UISegmentedControl, using the UITabBarController is the better option.

Related

Best practise in creating an uiview and presenting them in iOs

Is it a good practise to creates views in xcode and hide them and when required show them?
I am asking that because I prefer to create views visually and not in code.
If the view is to complex(a lot of subviews) should I create a new view controller to it?
I know there isn't a specify question here but I really need a clarification on this matter.
Regards
One of my first iOS applications had a tab bar and views that the user could switch between. Originally it was done by hiding and showing the right views depending on what the user pressed on the tab bar. This ended up being a complex disaster.
I then rewrote the app so that each tab bar view had its own UIViewController with its own set of views. That turned out to be so much easier to manage. (I also changed from using Interface Builder to straight code for creating the views, but that's beside the point and you can continue to use IB if you want.)
As for me, I prefer folowing practice:
Usually, a use storyboards,where views are placed, but if a view is complex, I create a separate XIB file, arrange all subviews there, and then in storyboard drag an UIView subclass and connect my XIB view with it.It helps to avoid mess in storyboard.
As for hiding views, I also don't recommend such practice as it can become very complex to understand your code and all those views are allocated when XIB is loaded, so the mobile developing rule "do as lazy as u can" is not met. We should try to spend as less memory as it's possible.
UIView is the best way to create iOS app, esp. if you want to reuse the code.
For example if you have same view to present in iPad n iPhone then using UIView can result in lots of similar code in View-controller
In another case if your view might need to have multiple table view it can be quite complex to handle each with delegates in ViewController. But separate view will solve this problem.
I have made my 1st open source code after learning how to use View
https://github.com/bishalg/BGRadioList
which I had learned from
http://www.raywenderlich.com/1768/uiview-tutorial-for-ios-how-to-make-a-custom-uiview-in-ios-5-a-5-star-rating-view
About the hiding view - I have used lots of hide and show view codes in my apps but believe me at one point it will become complex and unmanageable if you have lots of views.

Muliple UINavigationViewController on iPad

I would like to build the the UI as shown in the MockUp.
For this I need to have two UINavigationViewControllers Side by Side inside a TabBarController. And on the left side I need a VerticalToolbar...
What is the best way to handle this?
Thanks,
Stefan
You can use iOS ViewController Containment API's to achieve this.
Check 'Implementing a Container View Controller' topic in Apple Documentation for the same.
Also check this post.
Here I found a good article that points me to the correct use of UIViewController Containment :)
Creating iPad Dashboard Using UIViewController Containment

Alternative to UISplitViewController?

I have to make an app for iPad which requires a UISplitViewController- like view but with extra navigation bars on the top. Unfortunately, the native UISplitViewController does not have support for this. As an example of what I want, consider the apple documentation site which looks like:
But what UISplitViewController offers is a part of it (Master-Detail controllers only):
So my question is: What is the best way to do this? Should I subclass UISplitViewController(which, I'm a little less confident of) or should I use loadNibNamed: or is there some open-source project out there?
Edit I need to put images, buttons and a search-bar in the extra top bar.
What you need it MGSplitViewController. It allows you to push the split view controller inside a navigation controller.
You can also accomplish what you require by digging in the view hierarchy and planting your view there, but MGSplitViewController would be more elegant.
I've recently developed a library and published on gitHub for IOS devices both iPhone and iPad. It's act like an UISplitViewController but there ara more customization option that you can use. https://github.com/ytur/USController

multiple "content views" on the same xib

I have a ViewController (with navigation) that needs to show 7 different content layouts. I want to keep the same background and nav, the only thing that needs to change is the central UIView.
If I have 7 different UIViews on the same xib/storyboard, can I hide the ones I'm not using or will that ding performance?
Using segues won't work either because they make a mess out of my custom navigation and animations.
Is there a better way to accomplish what I am trying to do? Thanks for suggestions
solution
My design is too custom for using view controller containment so I decided to mimic the idea with a custom UIViewController and two UIViews. It's not too bad and it works rather quickly.
You should look into using view controller containment, then you can load your views from separate nib files and still provide your custom navigation and animations from your container view controller.
Note: This is only really supported from iOS 5.
Generally, it's a good idea to unload views that aren't visible, however, if your views aren't using too much memory (and/or cpu time) hiding them when they're not in use should work fine.
View controller containment is probably what you should be doing if each view has its own unique functionality (i.e. view 1 is a map, view 2 shows some about text, view 3 is an image gallery). UITabBar might be useful, but it depends on your app.
The performance hit would depend on your views' contents. If you haven't done so already, invest some time into learning how to use Instruments (apple's diagnostic tool). Watching the video titled "Optimizing App Performance with Instruments" in the developer resources would be a good start.
My design is too custom for using view controller containment so I decided to mimic the idea with a custom UIViewController and two UIViews. It's not too bad and it works rather quickly.

Place UIToolBar above UISplitViewController?

I'd like to place a UIToolBar above a UISplitViewController but Interface Builder will not let me do so (using the standard split view template as a start). I know I can implement different tool bars in each of the two views within the UISplitViewController, but I want one seamless bar that lies outside the frame/bounds of the controller, directly above it and right under the status bar. Please help.
Thanks.
This is not supported by the UISplitViewController. If you need this sort of UI you would typically create a custom setup to achieve this.
I'd construct a setup using two UINavigationControllers that are controlled using my App Delegate and just take it from there. There will be some extra work for you, handling rotation, but that's to be expected when doing custom stuff.
This shouldn't be too hard.

Resources