Impossible click+drag a CollectionView in Assistant editor - uicollectionview

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

Related

why IB sometimes doesn't add a subview to a view controller

Sometimes IB simply doesn't allow you to add a view as a subview to a UIViewController as illustrated here
If I drag a UIViewController from the object library and try to embed it within Mailbox View Controller.. it doesn't highlight, however it would work fine if I try to add it to the generic View Controller at the bottom (can the fact that Mailbox View Controller have a Customer Class MailboxViewController have anything to do with it?)
I'm pretty sure I can do this programmatically (which is what I'll try next) but I was wondering if there was a reason for this (and if there was a way around it).
update:
this is what i'm trying to accomplish: I was following the steps here to implement a segmented view controller below search bar like in the iphone mail app.. however I kept on getting an error saying that a view can only belong to one view controller at a time.. So what I'm trying to do is basically create a separate viewcontroller, reference it from MailboxViewController as an outlet, make the containing view of my search area the view of this new view controller (this is where i'm getting stuck) and finally make the searchContentsController property of UISearchDisplayController refer to the view of this new view controller. (if this sounds confusing, which I know it does, please refer to this answer)
From your screenshot, the view property of your mailbox view controller is a table view.
A table view in interface builder won't support the dropping of arbitrary views onto it as subviews - where would it put them at runtime? In IB the table has no content, it just has that visual representation of cells to let you know what it is.
You haven't said what you are trying to set up so I can't offer any additional help. Adding a subview programmatically to a table view probably won't give you the effect you're after either - a table view is a UIScrollView subclass, so your new view will either move off screen or get covered up by the table view adding cells.

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.

How do I add a new view to a single view application in Xcode

I started my app as a single view application. I have the view with various buttons and labels connected to code. I want to add a button that links to another view.
I found a tutorial that guided me to click on the project and add a UIView subclass. However there is no option for that ( I think because I started it as a single view application).
I'm pretty new to all this so if anyone can outline a simple way for me to do this that would be great! I am using Xcode version 4.3.2.
Thanks!
You need to add a new Objective C class. Please refer to this:
How to create new View Controllers in XCode 4.3
If you started the app as single view using xib file the to add a class just go to name of the project on the left pane and right click on it. Then choose add new file. The pop up will appear to allow you to choose what type of class you want to add. Depending to what the new view is you can choose uiview controller or uitableview controller and so on. Just make sure you check mark with xib for interface user. That should do it. Hope it helps.
Adrian

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

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.

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.