Clear text of UITextField in UITableView cell on button press - objective-c

I have a table view with two rows, each with a text field. One text field is for username and the other for password. When I click on a button, I want to clear both fields and replace the contents with the intial placeholders.
I tried [mytableview reloadData];. That just reloads the table view; the text fields are not cleared. The placeholders are appearing over the text entered while editing the text field, and the next time I try to edit the text field, the text is drawn over the first text.

on your button click:-
do yourtextfieldname.text=#"";
or if you have made a text field in table view methods so in that condition on your button click do [tableView reloadData] and at cellForRowAtIndexPath write yourtextfieldname.text=#"";
and set placeholder also.

Related

UITableView removing checkmark from cell on search

I am using a UITableView to display some items and i have implemented a UISearchBar to this UITableView.
If the user presses the cell, a checkmark appears (accessory type of the cell is changed) and when pressed again the checkmark accessory disappears.
My problem is when the user searches using the search bar, all the checked cells are not checked anymore, no more checked cells at all.
I've been trying to fix this and searching for it for a while but no results ...
Any help ??
Thanks you.
That is because your table view where you put the checkmarks and the table view that you see after you enter something in the search bar is not same. To have the same check marks on the search table view cells, you need to explicitly add the checkmarks.
I can't see the way you are adding and removing check marks. So, in theory, what you need is a way to know which cells have check marks. So, let's assume you have an array of items and a parallel array which holds the 1 or 0 to signal if the items have the check marks when 1 means check marked and 0 means no check mark.
Let's call this parallel array, checkMarkSignalArray. Now, in your cellForRowAtIndexPath method, you can do something like-
if(self.resultSearchController.active){
cell.textLabel.text = [self.filteredItemsArray objectAtIndex:indexPath.row];
if([self.checkMarkSignalArray objectAtIndex:indexPath.row]){
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}

Get cell title from table view

I have a custom table view and each cell has a title and a button. When the user clicks on the button, I need the title of that cell to appear on another view. How do I get this?
It's not very tough here are the 2 solutions:
When you are creating the cell, assign tag to the label you want to get the title value (or text value)
second option is:
If you want to get the title at the didselect select method just get the cell from the table view with the help of indexpPath.row and then extract the label and it's text. You can assign the tag in the custom cell design and then extract it from cell (once you get the cell).

Highlighted color keep on the table cell when I click back to the table in Objective-c

I have a table view in my program, (1)when I click on a row, (2)it will be changed to a view, (3)If I click back button, it will go back to the table list.
My problem is when I go back to the table list and the highlighted color still keep on the row, how can I erase the highlighted color after clicked on the row?
Thanks
(1)
(2)
(3)
You can do this in you tableView:didSelectRowAtIndexPath:
[tableView deselectRowAtIndexPath:indexPath animated:NO];

Uitableview cell text got hidden on edit Button

When i try to delete any row - while clicking the edit button - the delete button appears and the text on right side truncated from the end.
I want to compress it automatically while delete button appears.
You can try setting the textLabel property attributes to automatically truncate the middle of the string or set a smaller (minimum) font.
[[theCell textLabel] setMinimumFontSize:theSizeYouWant];
or
[[theCell textLabel] setLineBreakMode:UILineBreakModeMiddleTruncation];

my DetailViewController has text field. It appears empty at my first tap after that

I have a table view which has full of items getting from my database. I open my app. I tap one of my items in table view, then DetailViewController that has only text field does not display anything it is empty. But when I go back to table view then tap any other item again , at this time it displays value what I wanted to display.. It does it for my only first tap.. I have no errors and warnings.. What am i missing?
Sounds like you implemented tableView:didDeselectRowAtIndexPath: instead of tableView:didSelectRowAtIndexPath:.