Base UIViewController for entire app with views inside - ios

I want to create base view controller for my app, all other view controllers will subclass it. It will contain some controls inside.
How I can achieve that? For creating design, should I drag new View controller on storyboard and don't connect it anywhere (then You have warning all the time). i Would like to create outlets and make some base implementation. If I use xib file it don't have all guidelines, like one below status bar.

Related

Creating component of UICollectionView/UICollectionViewController by using Xib and Implement it in UIViewController

I'm trying to develop a component of UICollectionView or UICollectionViewController which I can use multiple time in my current project and also can be used anywhere by simply copy-pasting whole folder.
Requirements:
- Create an Xib of either UICollectionView or UICollectionViewController (which one is easier).
- Embed that CollectionView xib in my UIViewController, In my that UIViewController there are some graphs and also some pics that I've to show(collection view is for that).
- Basically I want to send a JSON file and some parameter if needed to that component and make the collection view running within that View controller.
I'm facing a lot of problems embedding both of UICollectionView and UICollectionViewController so what should be the best way and proper approach to do it?
You could use a container view to embed a view controller inside another view controller.
This is from Apple documentation:
Container view controllers are a way to combine the content from
multiple view controllers into a single user interface

How to share the view layout of a view controller

Basically until now I create a ViewController in the Storyboard, set its class in the identity inspector and implement the connections and behaviour in the class.
Now I have two ViewControllers (ViewControllerFoo and ViewControllerBar), both are visually the same, but the information and the implementations of the actions of the buttons are different. So I want to create a BaseViewController, with the view creation and common implementation and override some methods in the ViewControllerFoo and ViewControllerBar
If possible I'd like to keep both ViewControllers in the StoryBoard in order to create the segues that launches each one of them visually
How can I do this?
Note: I'm starting with iOS development.
View layout is something that works with view not with view controller.
You can create a simple .xib (or view) file and draw your layout here.
After that add this view to controller or specify that view as main view of this controller.
Or you can create a view class and place all elements programmatically.
Just think about storyboard as 'navigation' utility not 'view layout' utility.
Note: too many views on storyboard speed down your computer and look too ugly.
Draw view in xib to reuse it or create custom views classes/clusters to implement interesting UX/UI effects

Create View Programmatically in Objective-C Xcode 5

How should I go about creating a View for the storyboard programmatically? I want to access the labels from the first ViewController object made(automatically to call the IBAction methods of VC). I know that this first object of VC is the one linked to the view in the storyboard(?) and I need to change a label form another file, besides VC. I'm pretty sure the only way to do so would be to access the VC object that is linked to the view, or create one and not go with the default one that is created. If not, how would I go about accessing the labels of the view from another file?
You don't create storyboard objects programmatically. A storyboard is very basically an XML file Xcode uses to call different view controllers. The biggest advantage of using storyboards over NIBs is you can layout transitions or segues, and the advantage of NIBs or storyboards over initiating view controllers by code is obviously the visual interface. So your question doesn't really make sense.
If you want to reference a particular view controller's label from your storyboard you need to create a pointer to that view controller first, but changing it programmatically doesn't make sense because that's what storyboard is for.
That said you may just need to go look for your class name in your view controller's Identity Inspector in storyboard and then edit your label programmatically through an IBOutlet property.

Do I need a View or a ViewController?

I'm building a custom view with an xib file that contains various subcontrols. I've got some container control that needs to hold my custom view. I'm kind of unclear on whether I need to make a View that somehow loads itself from the xib file, or a ViewController that does this.
However it's done, I'd like my custom view to be reusable, and something that appears in the toolbox in Xcode, along side buttons and textboxes and such, so I can visually design other views containing my custom view.
What is the right way to do this?
Does your component manages other view controllers (like UITabBarViewController does for example)? If yes, make it a subclass of view controller, if not, and it's just a control, like a switch or a fancy button, scroll wheel etc, then make it a subclass of UIView.

how do i generate view controller code defined in a storyboard

Here's what i'm doing :
I'm creating an xcode project using storyboards, defining all my screens by drag'n'dropping view controllers and views, but then I need to actually fill those screens with something.
So, i create uiviewcontroller subclasses files in my project, and fill the class name for every view controller in my storyboard. Then, I need to manually drag'n'drop every view elements into my view controller one by one, to generate properties.
I was wondering whether xcode offered the possibility to simply generate all the uiviewcontroller subclasses directly from the storyboard with all the outlets properties already set.
No.You only have to mention outlets and actions for all components which you want to use.If its automatically creates all outlets and properties and you cannot use "code conventions" for your application as you like.Sometimes your labels titles are static and you dont need outlets.so you have to connect each and every component.
http://oleb.net/blog/2011/06/creating-outlets-and-actions-via-drag-and-drop-in-xcode-4/

Resources