I need help with using this customizeable checkbox: https://github.com/Marxon13/M13Checkbox I have already linked m13checkbox.h and .m classes and wrote import in bridge-header file, but i don't know how to create checkbox on my tableview and manipulate it.
I need to place checkbox in every cell by my own UITableCell class.
UPD.
I have done with adding checkbox in cell, but now i need to control it in addiction by my data in UITableViewController. I need to set checkbox to checked/unchecked state depending on my dataArray. I also need to set label for every checkbox from dataArray
Related
I have created an outlet for UItextfield in a custom.h file and created 3 UITextfields using tableviewcell and also assigned tag to each of the textfields. But I don't know how to get those textfield values and also validate them. When all the Textfield values are correct, it should show successful alert message when clicked on a button.
I don't want to use 3rd party libraries.
Add a listener to the textfield field change in the cell and create a delegate that is held by the controller. When creating a cell, you need to add a flag to the cell. When the proxy method is implemented, the correctness of the field of the textfiled is determined. The created flag is used to distinguish the cell from the textfield and recorded in the nsarray.
I need help with using this customizeable checkbox:
https://github.com/Marxon13/M13Checkbox
I have already linked m13checkbox.h and .m classes and wrote import in bridge-header file, but i don't know how to create checkbox on my tableview and manipulate it.
I need to place checkbox in every cell by my own UITableCell class.
UPD.
I have done with adding checkbox in cell, but now i need to control it in addiction by my data in UITableViewController. I need to set checkbox to checked/unchecked state depending on my dataArray. I also need to set label for every checkbox from dataArray
In your custom UITableViewCell subclass, you should declare a property similar to the following
#IBOutlet weak var checkbox: M13Checkbox!
Then, in the corresponding prototype cell in your Storyboard:
Drag out a UIView from the Object Library.
Change the class of that view to "M13Checkbox" in the Identity Inspector.
Position the checkbox and add any necessary Auto Layout constraints.
In the corresponding table view's data source, make sure that you are dequeuing cells with the correct identifiers.
When that UITableView is on screen, you should see a checkbox in each cell, assuming your tableView(_:numberOfRowsInSection:) method returns an integer greater than zero.
What is the logic i should follow to integrate a like button in a tableview cell?
How do you update a text label inside the cell signaling how many likes it has in real time IE: when you click the like button it either adds a like or removes a like?
The button also is highlighted when current_like = true
and not highlighted when current_like = false
Where do I update that kind of stuff?
How can you update a cells label and display the new label from within the cell? or is it NECESSARY to reload cell for row at Index Path?
The two main problems/steps you have to achieve are:
- Update the label with the new like
- Update the datasource of the table to keep the data persistent.
So, what I would make:
Set your custom UITableViewCell as target for the Button, so the cell can know when the button was clicked. In the target function/selector you should update the label.
Now, you have to inform the datasource of your table that the cell has a new like. You can create a protocol in UITableViewCell and set the TableDataSource as its delegate. Then, when the button was clicked you can notify the delegate.
You can achieve the same behavior with NSNotificationCenter, instead delegation.
Regards ;)
To change the cell's content without reloading you need to create a pointer to that cell. You can change your cell's parameters directly using a pointer without reloading cell. So it would be something like
self.myCell.label.text = something
And to assign the pointer to your cell you must put something like this in your cell adding method:
self.myCell = yourLikeCounterCell
I am working on a UITableView inside a UIViewControlller and I would like to add a new cell to a row, but in a way that the only thing showing on the table would be the user defined name, but hidden data (such as a hyperlink) would be retained too. The purpose is to open such hyperlink when pressing the relative button.
I'm using
[dataSource addObject:UserDefineddName];
and this adds the name to the row, but how can I add the data too, without displaying it?
I have labels and a button set up in IB and I was thinking that perhaps the link could be assigned to a hidden label, but it's not clear to me how to do it.
Please advise!
Many thanks
Create a class for your data with two properties, name and url. Then simply fill your data source with instances of this class instead of simply strings. In your cellForRowAtIndexPath do something like this:
titleLabel.text = [dataSource objectAtIndex:indexPath.row].name;
iOS Proficiency: Beginner
If I have a Xib with multiple fields that all need their own Picker View, what's an appropriate/canonical way to add multiple picker views on the page without getting the Design View all cluttered up?
1) Only add the PickerView programmatically and not via the XIB?
2) Use only 1 Picker object and populate it with different values based on the field
selection? (Possible memory benefits?)
3) Place the UIPickers on the View with a tiny height/width and then programmatically adjust height when necessary? Not even sure if the height is adjustable.
4)Combination of some of the above?
You can see in the image below, how cluttered it looks already even with just one picker view:
The view that you have with the text fields and picker views would lend itself to be part of a UITableView.
See the calendar app when you add an event.
You can set this up fairly easily by using a static UITableView.
I'm replying on my phone at the moment but will look for a tutorial if you would like.
If only one pickerView will be visible at once, then you should consider using only one pickerView and configure it's delegate/datasource so that you can give it a different datasource for each field.
Unless more than one is visible at once, there really isn't any reason to use more than one in your nib file. And even if you used more than one, you would still have to configure you delegate/datasource methods to handle each individual picker.
Hope that helps.
EDIT: It would be a little bit of work, but if you wanted the pickerView to animate in and out of the view whenever you need and if you wanted to clean your Xib up even more you could do the following:
Create a subview containing your pickerView
Set up a protocol on the subview to allow you to pass the selected value back to the view controller.
Set up your viewController to conform to the protocol on your picker subview.
Set the pickerView to be each textField's inputView.
Set the textField's delegate methods to configure the dataSource of your subview when editing begins.
By doing this, you have set your textField so that when it receives firstResponder that it will display the pickerView instead of a keyboard.