No User Interface pops up when I create a nib file for my Tab Bar Controller - objective-c

I am creating a Tab Bar Controller xib file that will house the tab bar controller. So I am highlighting my project folder for this and then creating a new file and then selecting the "Empty Template" from the i0S section on the left. But once it is created I am not seeing the User Interface that should populate when you create the NIB file. Can anyone show me what I am doing wrong possibly? When creating other XIB(NIB) files I haven't encountered this but then I again I have never used an "Empty" template for it before either.

Unlike other view controllers (e.g. UITableViewController) you should
not subclass the UITabViewController. Therefore, unlike other view
controllers, you don't subclass and then make your subclass the owner
of the nib, pointing at the view in the nib, with a customised view.
See this full ANSWER for more info of what to do it instead.

Related

Impossible click+drag a CollectionView in Assistant editor

I have a single view application then I added a tab bar controller.
On one on of the two new view, I drag a collection view and a collection view cell.
In fact, I follow this Youtube tutorial : http://www.youtube.com/watch?v=Pvvn1L2aPyA
, and I don't succeed to click+drag the collection View in a header file (2'20).
When I open Assistant editor with my collection view selected, the automatic file diaplyed is UIViewController.h. I don't think it's the good file and I can't click+drag the Collection View.
I tried to create a new subclass of CollectionView or ViewController linked with this View but nothing works. (I created an Objective-C file "PageCollectionView" subclass of UICollectionView. I changed the custom class of my Collection to "PageCollectionView and nothing change).
Can anyone help me to create a file where I can click+drag my Collection View and then try to follow this Youtube tutorial ?
Thanks
Pierre
In fact, I had to create a new View controller (File->New->File->Objective-C Class-> Name as you want (ex:DanViewController) and subclass of UIViewController).
And then in storyboard, select the Identity inspector (in Utilities) and set the custom class to the name of your newly-created class (ex:DanViewController).
By choosing this file now in your assistant editor, I can click+drag every controller of my View.
Hope it will help
Pierre

How to connect dataSource outlet of a Page View Controller using Storyboard in Interface Builder

According to Apple's documentation here, we should be able to add a Page View Controller into the storyboard and then optionally set the data source by connecting the outlets.
Creating a Page View Controller Interface Using a Storyboard
The Page-Based Application Xcode template creates a new project with a page view controller as the initial scene.
To add a page view controller to an existing storyboard, do the following:
Drag a page view controller out of the library. Add a page view controller scene to your storyboard.
In the Attributes inspector, set up the appropriate options.
Optionally, set a delegate, a data source, or both by connecting the corresponding outlets.
Display it as the first view controller by selecting the option Is Initial View Controller in the Attributes inspector (or present the view controller in your user interface in another way.)
I then defined a UIPageViewController subclass like so
#interface DetailsPageViewController : UIPageViewController <UIPageViewControllerDataSource>
but then when I tried to connect the data source outlet, it does not highlight the controller or allow to connect it. I have also tried implementing UIPageViewControllerDataSource on other controllers but I have the same problem of not being able to connect the outlet.
Can anyone help?
I failed to find a way to do it in IB. Have to use the following instead:
self.delegate=self;
self.dataSource=self;
Note that the Apple documentation states that UIPageViewController is not normally subclassed. Your UIPageViewControllerDataSource does not need to be a subclass of a View Controller. You can make it a subclass of NSObject.
Normally only things that appear on the storyboard, namely UI elements, are listed in the document outline that appears to the left of the storyboard (provided it has not been hidden). If your delegate/datasource is not already there, you can put it there, by dragging an 'Object' (yellow cube) into the document outline, in the appropriate scene.
Then click on the Object that you just added, and use the Identity Inspector pane to alter its concrete class to your data source class. It's then available to be used as the target of a connection in the normal way by dragging a line from the Connections inspector onto it.

Replace the TableView in a SplitViewController

I am looking to replace the UITableView in the MasterViewController section of a UISplitViewController. Instead of the UITableView, I want just a View so I can place UIButtons, UILables, etc in it. These buttons would then control what is shown in the DetailView section of the SplitView.
I have asked this question one other place and someone suggested that I create a subclass of the UISplitViewController. This person didn't give much direction, besides retaining the DetailViewController.h, .m, and .xib and editing the MasterViewController.h, .m, and .xib to my liking.
Here are the steps that I have taken:
Created a new project and selected "Master-Detail Application"
Unchecked "Use Storyboard" so I could get at the xib files.
Opened "MasterViewController.xib"
Deleted the "Table View" under "Objects"
Added "View Controller" to "Objects"
Changed "#interface MasterViewController : UITableViewController" To "#interface MasterViewController : UIViewController" in "MasterViewController.h"
Commented out anything under "MasterViewController.m" that was causing problems because they were referencing properties of the TableView, which is no longer there.
Then I get this error: -[UIViewController _loadViewFromNibNamed:bundle:] loaded the "MasterViewController" nib but the view outlet was not set."
Am I on the right track? If I am, could someone help me out with the error I am getting?
Otherwise, if I am going at this wrong, could someone point me in the right direction?
Thanks!
now, with storyboard in the latest Xcode, here's what i have done …
create a new Master-Detail project, and allow storyboard
open MainStoryboard_iPad.storyboard
click on the TableViewController and then delete it
drag in a new plain ViewController
ctrl-click-drag from the navigation controller that is the master view controller to your new ViewController
remove the MasterViewController.h/.m files, and create a new class that is a subclass of UIViewController
take the name of your just created replacement class and place it in the Class name of the Custom Class section of your identity inspector
now, add buttons and wire up the way you want to. if you stick with a single view controller in the detail portion, you should be able to simply refer to the detailViewController directly and fill it as you want; for multiples, you can probably use replace segues.
for iPhone, the steps will be similar. you'll have to ctrl-click-drag from the nav controller to your new ViewController and set up the replacement ViewController.h/.m files in the same way. the segues from your buttons will be push segues, or you can simply call performSegueWithIdentifier:sender: .

iOS Split View - Load XIB

I am new to making iOS apps. I want to make a Split View app so I can have topics on the left and the content on the right.
I want to be able to pull the xib file and display it on the right. How can I do this?
I have a basic one working where it changes image, but not views. I want to display the xib file relating to the selected one in the array. Any tutorial to show me how to do this would be great.
Here is the video I watched.
P.S I am new to this app development. Thanks.
A split view controller manages two view controllers.
When you create a view controller, you can specify the .xib file from which it should load its view.
It follows, then, that when the user taps on a topic, your code can create a corresponding view controller (see UIViewController's -initWithNibName:bundle: method) and set that view controller as the split view controller's detail view controller.
It's possible to have an existing view controller load a new view from a .xib using NSBundle's -loadNibNamed:bundle:owner: method, but that's usually more work with no real advantage over replacing the entire view controller.
As far as I remember, you should have access from your viewController to the property splitViewController, on which you can change the property "viewControllers" to any array containing the rootViewController at index 0 and the detailViewController (set to your new detailViewController) at index 1.
If you don't want to have sveral controller for your views, I remember having used NSBundle methods to load a nib file and assign it to a controller. I believe this is another possibility but you have to test it.

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.