I have added a tableviewcontroller object for my settings page. On this settings page I have a slider and a UILabel. The UILabel is a number (1-10) which is changed via the slider.
To implement this, I need to create an IBOutlet to the UIlabel, however IB doesn't seem to let me create this. How can I achieve this?
Thanks
you have to create it inside custom class of type UITableViewCell
which should be assigned to that TableViewCell That contain your label.
Related
I have a UITableView in my current project. Each cell is an object of custom class DecisionItem, which implements UITableViewCell. Inside each of these DecisionItems should be a UITextField named "descriptionBox". However, each time I run this app, descriptionBox keeps showing up as nil. Why is this?
This is what shows up in the console, as you can see, descriptionBox is nil:
This is my prototype cell:
My cells show up entirely blank while running the app:
These are things that I have made sure I've done:
Yes, DecisionItem has an IBOutlet variable named descriptionBox that is connected to the UITextField in the prototype cell.
Yes, I set the prototype cell's class to the custom class DecisionItem
Yes, I cast the cell to DecisionItem in the cellForRowAt function
Yes, my reuse identifiers are all correct.
What could be causing this error?
In your storyboard on the left side scene hierarchy right click on the DecisionItem cell and hover over descriptionBox to make sure it highlights the correct text field in the storyboard. If you see a yellow warning sign click the X and relink it.
I want to make "tableViewcell.selection = .None" , either by storyboard or code with minimum lines. I have tricks to do it, but I really willing to know if there is any other easiest possible way exist which I may missing in the apple documentation.
I am working with below components:-
UITableViewController
UITableView (Static)
UITableViewCell (no IBOutlet connected because its not required for my simple implementation)
Subviews of UITableView has IBOutlets
In .swift, didSelectForRowAtIndexPath defined because I want user interaction on click (no delegate method called because so far not required)
Is there any way to disable cell selection from storyboard.
Set the selection style of cell to None in storyboard.
Refer this:
https://developer.apple.com/reference/uikit/uitableviewcell/1623221-selectionstyle
I am interested to know how to add more than one piece of data into one line of data into a cell of UITableView.
For example in the StopWatch of the Clock App in Iphone, they are able to have more than one piece of data.
Lap Time Total
1 00.01.5 00.01.5
Interested to know how to add three values into one cell at a time...
You'll need to create your own cell, which inherits from UITableViewCell.
Here's an example of how to create your custom UITableViewCell.
You would have to create a custom uitableviewcell for that checkout this tutorial or refer to Apple Documentation for more detail
You could either subclass UITableViewCell, or you could choose the "Custom" attribute on IB on the cell, and drag and drop labels, buttons, and whatever you want into the UITableViewCell. Set tags on each IBOutlet you create. Then you can do like this in tableView:cellForRowAtIndexPath
UILabel *yourLabel = (UILabel *)[cell viewWithTag:tag]; // Set your own tag and outlet.
From there you can customize it just how you want, without having to subclass it.
When that is said, the usual way is to subclass UITableViewCell. That way, you can have each cell store information, and add the IBOutlets as properties to the CustomTableViewCell as normal. Then you could add the information to the CustomTableViewCell, and let the cell take care of the rest.
I wanted swipe a custom view into a UITableViewCell. I can set and use the swipe delete button but I want to have the same effect with any view.
Have you tried setting
#property(nonatomic, retain) UIView *editingAccessoryView
of UITableViewCell?
Why don't you try it will Custom cell & each having the UIView in cell.
That would be much easier way to manage if there are multiple view & user will also be able to scroll for all view.
Hope this trick would work .
I created a subclass of an UIView called smartView.
Then I created a NSInteger parameter viewID.
Now in the IB I change the class of a standard UIView to my smartView.
My question is how can I supply a value for my viewID parameter in IB?
Is it possible? If not, is there another way besides "Tag" parameter to give a UIView component a unique id?
I think the way to supply that value in IB would be to create a IB Plug-in.
See here for a tutorial, and here for the Apple Reference Document.
If you provide an IBOutlet for your smartView in the view controller then you can access it like:
self.mySmartView.viewID = _viewID;