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.
Related
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
Another Swift beginner here. I have a Stepper in a TableView cell which needs to update a label in the same cell. I got part of the way there by asking another question and I received a great answer here: https://stackoverflow.com/a/42877313/3692615.
I think I understand how the code is supposed to work, and my label is updating with the initial value, but unfortunately the stepper action doesn't seem to be connected properly.
I have tried:
Making sure I do not have redundant outlets in the connections inspector
Clean/Build project
Delete all outlets completely and reconnect
Tried changing the sender on the stepper action from UIStepper to AnyObject
I'm running out of ideas. Here is a screenshot of the connections inspector.
Here is the logic. Its basically a model class at the top. Then the outlets along with a property 'buyStat' to hold the current data source item and to update the stepper and label when buyStat is set. That's all working, but the stepper action below it is not. I can't get "stepper working" to print.
Then if it helps, here is my ViewController class
If anyone notices anything or has another idea for me to troubleshoot it would be appreciated. Thanks.
You've disabled the user interaction in your cell for row at index method:
cell.isUserInteractionEnabled = false;
You should remove this line.
xcode: I have set up the IBOutlets and the viewer and elements in the storyboard. But when I go to link them the IBOutlets are not listed. Yes I have set them up in the correct file, done this many times and linked many times. But today, for some reason my Segue layout changed and the IBOutlets UIImageView UILabel UIButton etc are not listed. I have also heard that it is not the best way to use the storyboard, that I would be better off not using it at all. So what is the alternative?
So two questions really. Where did my IBOutlet list go? And how can I do without the storyboard at all?
First of all check the custom class name you have given correctly or not for your storyboard
More over you dont want to use storyboard. use interface builder or do programatically.
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];
I created a sectioned UITableView and added a custom cell that includes a UISwitch. All this is done using the storyboard. However, when running the App (Simulator/device), the UISwitch does not look as expected (c.f. attached screenshot).
Any ideas on why this happened are highly appreciated (XCode 4.5.2, iOS 6.0.1). Note: creating a new UIStoryboard does not solve the problem.
I just got the answer to my question: I created a category on UIImageView that sets custom layer properties (e.g. shadowRadius). Setting a breakpoint on the corresponding UIImageView method, it revealed that the UISwitch called it.
I did not get to this point earlier, as I only had a single UIImageView before (and this one was supposed to have custom properties). Thanks for all your comments!