iOS table disappears - ios

I have a View Controller that have a tableView inside it which has different data in it . when inside the search bar I search for a data in the table, it remove other data and just show the data i was looking for. when i click on the data it push to next view. Everything looks fine but when I go back to the view the tableview will be disappears ! The funny thing in the same app I have other similar view with similar code, but it's ok over there. anyone knows whats wrong with it ?!

in the didSelectRowAtIndexPath i added [mySearchBar resignFirstResponder]; which is my searchbar's textfield and it's ok now , thanks for answers guys

Related

iOS Navigation Controller Background Glitch

OK, Ive looked everywhere for an answer, and I am unsure of what you may call this by a name - but I have detailed what my issue is below.
In my main.storyboard file, I have a view as a child from a navigation controller (i.e., allowing nav bar navigation) - being a MKMapView, which when you tap on a pin, it brings up the next scene.. This is all as it should be... (lets call it the "map" and the "detail" scene)
BUT!!!
When you hit the back button, the map view glitches and overlays the detail views background image over the mkmapview for about half a second. Would anyone be able to suggest what this problem is? Thanks soo much!
Due to stack overflow, I can't upload a picture just yet (reputation).. are you allowed to link externally?
Your help is very much appreciated.
EDIT: Ive uploaded a screenshot: http://tinypic.com/r/e19gtx/8
Try
self.view.backgroundColor = [UIColor whiteColor];
in ViewDidLoad.
Basically make sure your glitchy view has a background colour.
Did you use segue? Try manually pusing the "detail" view controller onto the map using
[self.navigationController pushViewController:#yourDetailViewController# animated:YES]
hope this works, i encountered this before.

How to use the edit Toolbar component to edit a VC that displays information

My problem here is not knowing how to utilize the edit button in a UIToolbar correctly.
Basically, I have 3 VC the first 2 are inherited from the Navigation VC and then I added a third.
The first VC displays an empty TableView until you add cells to it through the UIToolbar.
You then click on a cell it pushes to the second VC which displays information about that cell (think of it as a list of friends and the second VC displays the friends name and email). Now here comes my problem, I'm not sure how to properly use the edit button on the UIToolbar to edit the information on the second VC.
So I want to switch from the second VC to temporarily display another VC like you would in the iOS contacts app and then go back with the VC updated and displaying the info that was just entered on the Edit VC.
Im not asking for solution code just for guidance, I'm currently a student on break and trying to make something to keep me busy and occupied.
Thanks in advance to anyone who replies.
You should use delegate to update your VC. In your Edit VC, create a delegate with a function like "didFinishEditing". When you complete your editing, call that function. The implementation of that function must be write in your VC.
This topic may useful for you: How do I create delegates in Objective-C?

ViewController loses its properties when I go back

I have two ViewControllers. The first has UITableview that I push data from to the second ViewController. Whenever I go back, the first ViewController loses its properties - Its navigationbar background disappears and for example the sidebar menu does not work either. Is there any way I could reload it while pushing the back button?
Thank you
Sounds like you are probably doing your setup in viewWillAppear instead of viewWillLoad. This means that when the view will appear on return, the setup is happening again and perhaps leaving you in an unexpected state. Put breakpoints in your view controller delegate methods and see what order things are being called in and why.

hide keyboard in secondary viewcontrollers when pressing background storyboard

I've been scourging the internet and saw several promising answers but none that worked for me. The problem I have is that I have many ViewControllers that I placed in Storyboard mode.
Lets say in my 5th view controller I have some TextViews and TextFields that pops up a keyboard for user input when pressed. However I want to be able to hide the keyboard when I press the background.
I tried following the first and second responses here: How to dismiss number pad keyboard by tapping anywhere
But I dont think my set up is exactly the same as theirs.
Can someone please help me? Please be VERY SPECIFIC if possible and dont assume I know how to fill in the dots.
Thanks so much!!
edit. sorry for not being clear but I meant I want the app to dismiss the keyboard when the user presses anywhere on the screen (thats not another Text field/view). The link I show does this but my problem is that I am storyboarding so I have multiple UIViewControllers and I'm not sure how to get IBOutlets/IBActions to work for the "secondary" viewcontrollers. They only show up under the first/main one...
In your application delegate file,
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[self.window endEditing:YES];
}
you can use [self.view endEditing:YES];
have a look at the Apple docs for Ending a View Editing Session

Clearing a tableview's contents when back button pressed

I have a simple iPhone app based on a navigation controller. There are two view controllers, VC1 and VC2, both with table views. VC2 also has a custom table cell. When a user selects a row in VC1, VC2 is pushed on to the stack. When the user selects the back button it's removed. Typical navigation stuff.
The problem I have is that the data in the cells in VC2 persists when the back button is pressed, so that when the user selects a different row in VC1, VC2 is pushed back on to the stack with the 'old' data in the cells, before the methods in VC2 reload the data.
I want to make sure that the data in the table in VC is removed every time the back button is pressed. I've tried releasing the tableview using viewWillDisappear, but it's not working. What's the recommended way of dealing with this situation? I've looked at the docs but it's not obvious (to me at least).
Try out this code snippet in viewWillDissapear or dealloc method.
if(yourTableViewCellObject) [yourTableViewCellObject release];
if(yourTableViewCellObject) yourTableViewCellObject=nil;
This might work.
I've used this technique several times since I asked the original question. As I mentioned in my comment to #Aditya, I've found that the easiest way to deal with this is to use viewWillDisappear to hide the tableview with the 'old' data, and when the user navigates back to the page, wait until the 'new' data is loaded into the table before making the tableview visible again.

Resources