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

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:.

Related

How to display UISearchbar on pulling a table view or a view

I am trying to load a view simply with a tableview. And when i pull the rows down i need to
display a search bar on top of first cell of table view. Every time this search bar should
appear only on pulling down the table view.
I tried this code in viewDidAppear: but it dint worked for me.
self.tableView.contentOffset = CGPointMake(0, SEARCH_BAR_HEIGHT);

Handling tableview cell selection from other view controllers

I have a tableView with custom table cells which displays a list of sayings. While selecting a cell (say "saying1") from the tableView, the cell will get selected and will moves to next view controller for showing an explanation of selected saying. In that view controller two buttons "Previous" and "Next" are there for navigating to previous and next saying. So user may select next button for seeing next saying (say "saying2"). But the problem here is, In this stage when i navigate back to my tableview, the cell selected will be "saying1" not "saying2".
In order to solve this problem, i collected the currently selected sayings ("saying2's") index from array (ie,index will be 1) and passed it to the previous tableView through segue and converted that value into NSIndexpath. After this step i don't know what to do. Please help me in solving this.
You can specifically select a cell by calling following method present in UITableView class :
selectRowAtIndexPath:animated:scrollPosition:
refere to following link : https://developer.apple.com/library/ios/documentation/uikit/reference/UITableView_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableView/selectRowAtIndexPath:animated:scrollPosition:

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).

Clear text of UITextField in UITableView cell on button press

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.

Is there a simple way to detect if a UISearchBar is exiting "Search Mode"?

I'm trying to set up a UISearchBarDelegate
My first attempt was to clear the search results when searchBarShouldEndEditing: was called, but I discovered that this gets called when scrolling through the search results, which is not a time to be getting rid of the array of them.
My next attempt is searchBarCancelButtonClicked: - but this doesn't get called if the search bar is empty and they tap the space below (where a greyed out view of the table view is showing).
So how do you know when to switch from returning search results cells to returning regular table view cells?
Thanks for any help with this.
You can check which table view is requesting the cells. searchDisplayController.resultsTableView is what requests your search results cells. Just check for this in cellForRowAtIndexPath