I am getting a story board error that is connection imageInCell cannot have a prototype object as its destination. I am trying to connect an image view to a cell class and I am getting this message. I am trying to use the UICollection View. I have added this code and is getting the error
#property (weak, nonatomic) IBOutlet UIImageView *imageInCell;
For some reason even I delete the code I still have the error remaining. Any help is greatly appreciated.
Assuming that you're attempting to create this property somewhere other than in a subclass of UICollectionViewCell, it makes sense that this would generate an error. At run time, you would have one reference to multiple image views and wouldn't be able to properly configure them.
Instead, create a subclass of UICollectionViewCell and add that property there. Then you can go to interface builder and modify "Custom class" in the Identity Inspector the your new subclass and link the image view in the prototype to your property.
Now, after importing the new cells class replacing the UICollectionViewCell in cellForRowAtIndex, etc.. with your new one, you'll be able to do things like [myCell.imageInCell setImage:someImage];
Related
Im struggling to fix one issue with IBOutlet in Custom Table View Cell. Actually I have a tableview with custom cell, designed in storyboard itself, there I have 4 labels to show different kind of information to user. All 3 labels are getting values, but one label is showing nil. I checked everything like connections from storyboard and awakeFromNib(). But still it is getting nil. I will appreciate someone help in this..
It can bee solved by checking the connection of that perticular IBOutlet. The only reason is the IBOutlet connection between the class and the storyboard is not proper.
What I'm trying to achieve:
Trying to achieve Google-Now-style like custom TableViewCell with couple of buttons on each card (refer to the provided screenshot here). Using Storyboard.
Problem
I was able to make the card like TableViewCells, but whenever I try to place a UIButton on the card, it will either cause a compiler error or a runtime error.
Current setup
My current storyboard set up looks like this.
Here's my code for the TableView.
What I've tried so far
Drag and dropped the UIButton on top of my card view, which looks like this. Button get buried down somewhere under the tableview? Button does not appear like it should and once I create an outlet to the actual code, compiler error (invalid outlets cannot be connected to repeating content).
Placed the UIButton on top of the Content View. This outputs in same result as above.
Placed the UIButton on top of the View. Now this actually shows the button on the storyboard, however it causes a runtime error and crashes while it tries to display this ViewController.
Here is how it's set up on the Storyboard.
Now, what am I doing wrong here? I've looked at several tutorials on how to place a UIButton on a TableViewCell and it looks dead simple as just placing the UIButton on top of the cell.
EDIT: So I did add a new class for the petListCell and assigned it on identity inspector. I place it on the Card Design View, where the button should belong to, and it is now giving me following compiler error: "/Users/.../Main.storyboard: The feedingHistoryButton outlet from the YourWoofsViewController to the UIButton is invalid. Outlets cannot be connected to repeating content."
You need do like this.
create a subclass of UITableViewCell like PetCell
change the class of the cell in storyboard from UITableViewCell to PetCell
link the button to PetCell like you did with the ViewController
You can change this.
create First a subclass of UITableViewCell like PetCell
And change the class of the cell in storyboard from UITableViewCell to PetCell
link the button to PetCell like you did with the ViewController
I decided today that using static tableViews would suit my app better than dynamic ones.
Each cell has a label, and a UITextField
I subclassed one of the static cells and then tried to create IBOutlets for the label and textField... only it wouldn't work. Zero IBOutlet functionality when it comes static cells apparently and their subclass
I can however drag in IBOutlets to the UITableViewController these cells are apart of
So, essentially I would have a UITableViewController with outlets for each cell, each cells textField, each cells label, and potentially any other properties I want to add to the cell
I didn't want that much annoying code so I tried using dynamics
I was able to create IBOutlets for each object the way you can normally expect
I again decided against dynamics UITableViewCells, and switched back to static...
ONLY the static cells now have IBOutlets connected to them (they didn't disappear or throw errors when i returned to static UITableView)
I can access the cells properties by using cell.textField which is a lot better than a billion IBOutlets for each object on the cell
My question is... Why can't I create IBOutlets on the subclass of Static TableViewCells
Is the way I did it the only way, or is there a better way? I would hate to keep switching back and forth, but it allows me to get rid of dozens of lines of code I'll do it
When you create IBOulet for a UITableViewCell and you try to connect them on your StoryBoard, go to the left bar (where the objects of your view controller are) and press Ctrl + Click over your custom cell. Then the IBOutlet object will appear in a popup and you will be able to link them.
I am trying to add a container view to a UICollectionViewCell in interface builder but Xcode issues an error error: Illegal Configuration: Container Views cannot be placed in elements that are repeated at runtime. Will making the UICollectionViewCell static would solve this? If so, how would you make the UICollectionViewCell static?
What I guess you are trying to do, is placing a UIViewController into a dynamically generated UITableViewCell.
If so, this isn't possible if the cell you are generating are dynamic. If you know a priori that the cells will always be in a fixed number, you can generate them by Interface builder setting the cells to static.
If instead you only want to add a container view to your cell in order to put other objects in it, you need to add a UIView object, not a UIViewController.
I have quite a large project (~20 scenes). One of which is a TableViewController with a custom UITableViewController class. I have given the cell a reuse identifier, and added a label to it. When I try and Ctrl+Drag the label to the UITableViewController header file to create an outlet, I get the following error:
error: Illegal Configuration: Connection "tableInfoView" cannot have a
prototype object as its destination.
What is this? Am I overlooking something obvious? Or do I need to create a custom cell class and drag the outlet to that? If so, how do I then specify the data which is displayed uniquely for each cell from the UITableViewController?
In fact you can't just make an outlet from a dynamic cell prototype in the UITableView delegate view controller.
You'll have to subclass UITableViewCell and then attribute this class to your prototype.
Then you can Ctrl-Drag from the Label to the UITableViewCell subclass header file.
Finaly you can access to this outlet in the delegate code after having imported the UITableViewCell header file in it.
This is documented by Apple there at "The Technique for Dynamic Row Content" section.
or you could give the label a tag (e.g. 100) and use
myLabel = [myTableView viewForTag:100];
to get the label
I had the same error myself. Just to add one more potantial root cause for future readers:
In my case I copied a control (a Button in this case) from one prototype cell to the next and the action still referred to the neighbor cell. My table has several different prototype cells.
The fact, that it acutally was a proper subclass of UITableViewCell which was properly connected to the prototype cell made it difficult to actually see the mistake.
Tag the label and you can reach the label anywhere in the viewcontroller like with viewWithTag from the table view.
UILabel *destinationLabel = (UILabel *)[self.tableView viewWithTag:1];
destinationLabel.text = #"Label Destaination";
I faced the same problem but later it turned out that it was just a silly mistake.
I mistakenly dragged the label from Cell to my controller's #interface
This could be your problem too. just cross check once.
Set the right reuse identifier used in .m file in the Storyboard for the Prototype cell.I had the same situation and this helped me
After doing every thing right if problem still exist then just removed all outlets and rejoin them carefully and it worked very fine for me.