Connection for label/image view outlet for collectionViewCell not populating. ( no errors) - uicollectionview

I am trying to connect a label and image view outlet for a collection view cell with control drag, since each photo and label will be different. I have already done this before with a previous view controller. However this time when I try to get the outlets to connect to the cell class. It is not populating. Is there any reason why this is happening?
I also want to note that this view controller will be connected to another view controller I previously made that also uses a collection view. Could this be the reason why I am having this problem? I already created another view controller class and connected the collection view datasource and delegates. I also tried connecting the label and image view to my other collection view cell class that worked for the other collection view cell and it won't even populate there.
Worked fine with my first collection view
When I drag it doesn't populate outlet connection

Ahh, so I forgot to set the actual cells custom class property.
That fixed it.

Related

Cocoa Bindings "Selection" not changing when table rows clicked

Hello there: I have in essence a master-detail application with one master view-based NSTable view and two detail views. My master NSTable loads and displays data from a Managed Object Context correctly. One of my detail views should load the image of the object in selected table row. But here is my problem that no one else on the Internet seems to have:
My "selection" object isn't changing. I did bind the the value of image view on my detail view to the Array Controller, and controller key is: "selection", model key is "image". The image view only loads the first object's image in the table, and if I click/select on other rows, the image isn't changing. So it seems like "selection" object is always the first object. Since this is all done in Interface Builder, I don't have any code to show, sorry.
Does anyone know what is going on? Why is the "selection" object always the first in the table? Thank you!
You need to bind the NSTableView’s selection to the NSArrayController’s, like so:

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 to set action for a button inside the NSCollectionViewItem

I was using an NSCollectionView to show a list of pictures in the binded array controller, also, I want to add a delete button on the left-top corner of each picture so that when someone press the button, it will remove the corresponding object in the array controller.
However, when I tried to make the NSCollectionViewItem a subclass of my custom class, and set action of the delete button to a method written in my custom class, It reports an error like
'Could not connect the action XXX: to target of class NSCollectionViewItem'
Also, I failed when trying to add an array controller object in the NIB file.
What should I do to make everything OK?
It seems we can add a button in the default Protype of the CollectionView, and link it's target to the controller.

Iphone : what do I need to do to a nib file to an exisitng object

I have tried using an outlet to connect my tableview controller to my object, setting the nib name in IB and setting the class in IB but it still wont link? I know this as im trying to set my table view to 'grouped'
Thanks very much.
It's a little unclear what the problem is. Do you have the outlet visible in IB, but it's not letting you draw a little line to the table view? In that case, double check the class of the outlet. It should be the same (or a superclass of) what you're trying to hook up to it.