Not sure but maybe I just missed the easy way...
What I am trying to achieve is:
I have a tableView with a tableViewCell, in this tableViewCell I have a textfield in which the user can make an Input, I want to save that input when he clicks a button.
I know how to do this with the prepareForSegue function but I want do it just with the Button Action. Is that possible? Or other question, when I use the didSelectRowAtIndextPath function, can I directly access the content of the cells outlet, textfields, labels, buttons....?
Thanks for any comments...
Related
So I have a table in the accordion style. When a row is clicked, five radio buttons are displayed. Then, users should be able to click on those buttons. It successfully displays the buttons, but when the buttons are clicked, instead of highlighting the selected button, it shrinks the row itself. I think this is probably because I implemented each set of the label part and the option part as a single row, just in different UIViews. I believe clicking on the view that contains buttons is overridden by clicking on the row(label + options). Its really hard to explain, but I think a solution could be restricting selectrow action of the table to only certain portion of the row.
Is there a way I could achieve this? If I cannnot, is there other ways to implement the accordion table to be used as I described?
I am having a really hard time trying to explain this. If you have any questions, please let me know.
table
As per my understanding you van give a try to below steps:
Disable the row selection so that you can avoid row selection. Usecell.selectionStyle = .none
Secondly for your button in row set the IBAction in controller class and in Storyboard connect those actions to specific buttons.
Suppose I have a tableview cell.
On this I have an UIVIew rating control which works by adding buttons as subviews.
When the user clicks besides the buttons, but still on the rating control, the click is passed through to the underlying cell. I do not want that.
I am thinking there must be a proper way inside the rating control code (derived from UIView) to catch all clicks passed to it and simply never pass them through any further to the cell.
How can I implement the login screen in the setting like the image below?
I can't find the tutorial..
What I know is grouped table view only, I want to know how to do the username and password text input like that
Its simple first TableView Cell have
UIImageView
UITextField
UITextField
The others are more simple just need to manage the click event to provide appropriate implementation.
If you want a tutorial about handling UITextFields in tableview here it is.
I have a tableview controller inside a navigation controller. This table simply shows one textfield in each row. In my navigation controller I have a “Done” navigation item that gets all the values entered in the textfields and shows the next screen.
The tableview controller implements UITextFieldDelegte and textFieldDidEndEditing to store the values of every textfield in its datasource (array of strings). In cellForRowAtIndexPath I also assign the delegate of the text fields to themselves. This all works well if I tap on the different textfields, I see how the datasource is properly updated.
My problem is when I do this sequence: type a value in one text field and then tap on the “Done” navigation item. I see that textFieldDidEndEditing is not called so the value is not stored. I also tried with textFieldShouldReturn and textFieldShouldReturn but nothing.
I have read many similar posts and I think the problem is that the "event" is being caught by prepareForSegue instead of textFieldDidEndEditing. If this is correct, I don’t know how to deal with this since I don’t know how to identify the indexPath of that “last edited textfield” when the Done is tapped.
Another related question: I have seen two approaches to get the indexPath of the cell containing the textfield when textFieldDidEndEditing is called:
1) textField.convertPoint + tableView.indexPathForRowAtPoint
2) tableView.indexPathForCell + textField.superview
Both seem to work well without differences (except for the issue that I just stated). Is any approach better than another?
Many thanks in advance for your help!!!
PS: if possible, in Swift code, please!
On click of done button you can add this line,
[self.view endEditing:YES];
This line will resign your currently active text field, and will call your text field delegates.
If you are displaying all text fields within same table section in that case you can assign indexPath.row to textField.tag, and using that tag you can create indexPath.
This is how you can address this:
Step 1 : Keep track of your active text field. You can keep a strong reference to it and set it whenever a textField is activated. Something like this:
self.inputField = iCell.inputField;
Step 2 : Once your Done button is tapped, add below line in action handler.
[self.inputField endEditing:YES];
PS: Alternatively, you can simply call [self.view endEditing:YES]; without the need to track the current active text field. I, personally, go with keeping reference to textfield as it helps me doing other stuff around current active textfield.
I have UITableView where each cell consists of two UILabel, I want to show up keyboard when the cell is selected? Is it possible with UILabels?
If you just want to pop up a keyboard, you can add a tiny invisible (transparent 1x1 with transparent text) UITextField anywhere in any visible view and make this text field first responder to pop up a keyboard. Then you can redirect the input text to any of the two labels (or somewhere else) using the text field delegates to capture the input.
Yes, the label has to conform to the UIKeyInput protocol. Note that this is an either-or proposition. If the label conforms to UIKeyInput, then when it becomes first responder, the keyboard will be displayed, whether you want it or not.
I'm not sure how you mean this exactly since it is obviously not possible to edit two textfields for labels at the same time. Hence the following assumes you want to show the text in your cell using UILabel, but want to be able to edit the cell's text.
You can't directly use the keyboard to edit UILabels. The easiest solution is to directly use UITextFields instead of the UILabels.
An alternative is to have both a UITextField and UILabel in the cell. Then show the textfield (by settings itsß hidden property toYES`) when the cell is selected and hide the label. When editing is finished, do the reverse (i.e. showing labels, hiding textfields).
To show the keyboard directly after selecting the cell you can call [someTextField becomeFirstResponder];. To check if the user is done editing (and e.g. tapped the return key), you can set the delegate of the UITextField.