View Controller Management in IOS - objective-c

I need help with my control viewers in Xcode. In my storyboard, I created a navigation view controller. In which I created one view controller as my root view and added several objects in it.
Now in the general way, I'm trying to Ctrl + drag Element onto my View Controller. It doesn't show any Blue line like it is supposed to so.
Also I wish I can get some explanation or tutorials describing the method of creating views and controllers and linking them.

This is great tutorial to understand storyboards(single view for all the views in application) and Segues (transition between views). Go through both parts.

Related

UISplitViewController - Multiple Detail View Controllers via storyboard segues

I'm trying to do a project for the iPad in which I'd like to utilized the split view controller. I'll be having different detail view controllers for each of the cells in the master view controller.
I saw one solution how to do this via storyboard segues in this site.
He basically linked each of his UITableViewCell to different detail view controllers. But I'd like to know if this is a "stable" or a "good" way of doing this. I mean, is it any better or as stable as doing it programmatically? What would be the consequences of doing his method, if there are any?
Here is the link to the solution I found
This is kind of a tricky one, even though it's an incredibly common use case.
1) One idea is to have an empty root view controller as your detail and it handles managing segues under the hood to quickly segue to the detail view you actually care about, utilizing the "replace" segue. This should "technically" fix having the "back" button at the top left and still allow you to pop to root and not have it show the empty controller. Haven't tested these though, so I'm not sure.
Edit: In Xcode 6, the "replace" segue is conveniently handled by a "show detail" segue which is used specifically for this type of view handling on Split View Controllers. I recommend using this method exclusively in new projects. See sample code.
2) The other idea is to have separate navigation controllers in your storyboard (one connected, the rest all stranded). One for each detail view type and tapping on the master menu will simply swap the navigation controller for the detail view to the one you care about.
Code similar to this in AppDelegate:
self.detailNavigationController = [self.masterNavigationController.storyboard instantiateViewControllerWithIdentifier:#"MyChosenNavigationControllerStoryboardId"];
self.splitViewController.viewControllers = #[self.splitViewController.viewControllers[0], self.detailNavigationController];
self.splitViewController.delegate = (id)self.detailNavigationController.topViewController;
The downside to this second way is that in memory tests, it doesn't appear that swapping a new nav controllers in frees up all of the memory that the old nav controller was using. So it's good to use for simple apps but not for anything crazy complex.

Storyboard with NavigationController and TabController

It seems like this should be easy to figure out, but I haven't had any luck this afternoon. I threw together this quick, simplified storyboard mockup of my problem.
Basically, I would like the table view controllers below to also be in a tab bar controller (in addition to the already present navigation controller). The tabs would switch between the two table view controllers.
Right now, the view controller with the buttons acts as a sort of menu. Each button leads to one of the table view controllers. Ideally this view controller would not have the tab bar visible, and would only be reachable from back buttons on the nav bars of the table view controllers.
I've tried a few different ways of embedding into a tabbarcontrollers but none of them produce the desired result:
-I've tried selecting both table view controllers and embedding those in a tab view controller. The tabbar doesnt show up in simulator, and the 'unreachable scene' warning appears.
-I've tried embedding the initial nav controller into a tabbarcontroller. This creates a tab entry for the first 'menu' page. It also causes issues with push segues once I connect the tableviews to the tabview.
I would be fine implementing some programmatic options on top of the storyboard, I just chose storyboarding for this project since it's a relatively simple presentation of data.
What is the proper way of going about this? Thanks!
A tab bar controller needs to be the root view controller of your view hierarchy. It goes against the HIG and Apple's standards to put a tab bar controller inside of any other type of container controller.
From the Apple docs:
When deploying a tab bar interface, you must install this view as the
root of your window. Unlike other view controllers, a tab bar
interface should never be installed as a child of another view
controller.
So, the bottom line here is you need to rethink your design. One option would be to set the UITabBarController as the root view of your window, and then have each of your UITableViewControllers inside of a UINavigationController, which is placed inside of the UITabBarController. In this way, you still get the navigation bar, and stay within Apple's design guidelines (you also won't get those pesky warnings, and Apple may even be throwing an exception nowadays if you try to install a UITabBarController as anything other than the root view of the window).
I accept JMStone answer but we might get into situation where we need to put tab bar controller inside other controller especially table view controller.
Please refer Storyboard navigation controller and tab bar controller
and also the good example by Matthjin: http://cl.ly/VQLa
Hopes it help some one who want to put tab bar controller inside table view controller and wants proper navigation.

Rotate View which is insider another View

Today, when implementing my program i get a problem.
I have three types of views (small view). From them i make another view. (Templates)
When full view I add to viewcontroller.
As i think, willAnimateToRotation... For small views will not work correctly, because they are inside template. And template inside ViewController.
When app rotates i need to change frames for small views.
What should i do? How to perform frame change in rotation?
Views are adding to template with addSubview and template to VC also. I pass data to small view from template.
I'd translate this as a ViewController containment problem. You need to forward the rotation messages throughout your view hierarchy, otherwise it'll never reach your small views.
Best thing to do is to look at the documentation here:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html
Go to the "Implementing a Container View Controller" sub-heading for a description and the "Managing Child View Controllers" sub-heading for relevant code.

Change view of detail pane on UISplitViewController

I am working on an app to try and learn a bit more about the cocoa touch framework and am starting to use the UISplitViewController. From what I have learned so far, this has a property called viewControllers that is an array containing the master and detail view controllers for the app.
What I am trying to set up is a folder navigation system in the masterVC, then when a specific file is selected, it is opened in the detailVC. I have got the folder navigation working and can pass the details of the files between the two view controllers.
My problem is that there are several types of files that require different views to display them correctly.
For example a jpeg image will have an image viewer, whereas an html document will have a web view and a txt document will require a text editor view.
What is the best way to change the view controller of the detail pane?
Am I better to have a single View controller and swap different views in and out depending on the file type? Or is there a way to completely remove the viewcontroller and add the appropriate one in its place?
Thanks
I would think you should use multiple view controllers. There's bound to be a lot of logic in each of these individual view controllers you mentioned that should be properly contained within its own view controller.
As for displaying the appropriate view controller, you can easily add a view of a UIViewController to any UIViewControllers view, by doing: [self.view addSubview:myTextEditorVC.view]. So in other words, your detailVC could handle the logic of knowing which type of UIViewController it needs to display, instantiate that UIViewController, and display its view within the detailVC's view.
Hope this helps!
You should be swapping out different view controllers. In Xcode 6, you can use a "Show Detail" segue from the master to point to a different navigation controller that contains your different detail view.
Here's an quick example.

iPad: Split view Controller

I am creating split view based application for iPad.
I have 1) a root view controller 2) a detail view controller
It is like menu and submenu.
Here I am planning to do. I would like to have navigation in root view controller.
It is recomonded to use or not. If it is recomended how is it possible.
There is a function in the Detail View Controller for showing or not showing the popover Button. Possibly you could adapt that in the App Delegate for the whole Detail View Controller? Just go through the source code provided by Apple. It is all well commented.
Not sure what you're asking. If you're asking whether it's recommended to do it like how you describe, then yes, that's the most recommended way to do it.
Root view controller (the smaller left side menu) usually contains the navigation stuff, while the detail view controller (the bigger right side view) contains all the detailed stuff.
You might want to take a look here for a How-To.
Other documents can be found here.