So i have a search page. The word the user searches is passed to the next view controller. Now instead to using prepare for segue and passing the value, I store it as a global variable and just to a performSegue.
The problem is when I go back using the back button of the navigation controller, the new data doesn't reload when I click on search. It shows the old data.
Link of the images is given below. Now 1st one is a search for Rahul. It shows the correct result now the next is when I go back and search for Rohan it shows the result for Rahul itself.
https://i.stack.imgur.com/irUwo.png
https://i.stack.imgur.com/fthOm.png
https://i.stack.imgur.com/F7wKJ.png
Once perform to the result view controller, ask your main thread to call tableView.reloadData() after you received the new global value you pass. If this can't help you, please provide your code so that we could help you by clearly understand your situation.
Related
I'm building an app which has 4 screens, on the second screen the user will set time by date-picker on tableview.
There are few times to be set (depending on array.count).
On the third screen the user will set the location, and on the 4th screen user will see info from API and the time has been set by the user, also on tableview cells.
In case the user wants to change or update the time he set in one of the cells to different time, I need to be able to go back to the second view with all the input user added already remain, and the user can change only the cells they want to change, without adding all the time all over again.
When I'm using segue it creates a new 2nd vc and all the previous info erased.
I thing you have to use delegate to propagate this information from whichever screen to which ever screen you want. In Order to achieve that you have to loose the segue.
https://medium.com/#nimjea/delegation-pattern-in-swift-4-2-f6aca61f4bf5
In this link Delegation pattern is explained very well. Please refer that.
I use segue to perform the page jump from table cell in my.
I randomly got this issue in different places in my app. currently two places, the index table view and the setting table view (the setting one occurs first time this morning).
Methods in the destination controller are called according to the log."viewDidLoad","setup fetch result controller"..etc, but the app just stops there, doesn't response to any of my actions any more.
Any idea about that? Thanks in advance.
I am trying to write a project but with out success i need help:
in the first view i have UITableView with a + on the navigator bar than after i push on him
I open a another view there i want to add a first name and after then i click "Done" i want the name i wrote in the textfield will appears on the first view
and thats is my problem the name are not appears in the first view and i have not bug or error .
what can be missing in my project all the button are connected.
I need some help please.
Since you're not showing code, I have to have a pretty general description here. With a button in the nab bar (which is what I think you're talking about) the button calls an action method. Your action method is what moves you to the second view.
Even if your button is "wired up" correctly in your xib file, your action method may not be doing the right thing. I'd try setting a breakpoint in your action method to 1) see if it gets called and 2) step through to see if you're creating a new view and pushing it on the UINavigationController's stack.
I have a TableViewNavigationController. On my first page, i have displayed a table-view, and on the navigation bar there is a add button, where the user could add a record.
once the user clicks on the add button, a UIView will be displayed and the user could enter details and submit, and then when the user clicks on the back button on the TableViewNavigationController, the first page which contains the table-view is displayed with the added record.
But, for me multiple records are displayed, and when i restart the stimulator it shows the correct set of records. Why is this and how can i prevent this?
EDIT : Can someone tell me which method fire's when we click the back button of the TableViewNavigationController ?
Are you updating the datasource of your tableview with the right array-data?
If not,
[yourTableView reloadData];
Should fix that.
You likely need to use the reloadData method for your tableView when returning to the table. And possibly refresh your data. Is it coming from an array or using fetched results controller? Either way, it sounds like you're seeing odd results because the data has changed.
You should show us some code, so we can help you more.
The method that get's called when you change a view is the viewWillAppear
Since you mentioned that you are reloading your Table Data Source, are you sure you are adding the new entry to your existing Data Source (your Array) ?
Is your Array an mutable Array, so you can add the new record to it?
Greetings. I've got a nav-bar application that's misbehaving. I've got two buttons, one that shows all results from my database and another that shows a subset of my database. Of course, each button has its own action method. Both of these methods instantiate a view controller object of the same class.
If I start the app and only click the "all results" button, I do see all results. The goofy thing is that when I click the button for the subset of results (and see the subset of results), click Back on the nav bar, and then click the first button for the entire set, I see the subset again.
While debugging with break points all over the place, I noticed that the dealloc method of my results view controller doesn't get called. However, when I click Back and then click the all-results button, the alloc/init methods are indeed called again for my results view controller.
So even if I have a blatant memory leak, how is it possible that my freshly allocated/initialized view controller object has the same data as that of the previously instantiated view? Stepping through the code made this problem seem even more bizarre, as it appeared to be behaving properly...just yielding old data.
Any advice at all would be great. Thanks!
Calling "reloadTableData" on the table view should ensure the data is refreshed. Call that in the action methods.
Why do your buttons repeatedly instantiate the view controller? Why not have pointers to the view controllers as instance variables that you only have to set once and then can use at will?
This is just a wild guess, but it could be related to the reuse of tableViewCells. Try always creating a UITableViewCell, avoiding the reuse-identifier to see if the old data persists.
I figured out what was wrong a while ago and thought I would answer my own stupid question. :)
I had forgotten that I made my Database class a singleton and put a master pointer to "allResults" in the app delegate class.
Thanks anyway for your input. Every little bit helps me understand this new environment better.