Reputation: 39
I have a tableview and two dropdown. When I am changing dropdown value cell data are repeating two times. I want to change my tableview cell data according to the dropdown changed value. When I will change the dropdown value the first data should be deleted and again it will be loaded according to the value changed in dropdown.
I had tried tableview.reloadData() in viewDidLoad() and also in my dropdown changed action method but it is not working.
select_activity.didSelect{(selectedText , index ,id) in
self.select_subactivity.isUserInteractionEnabled = true
self.select_subactivity.text = ""
self.getListOfSubactivity(activity_id: id)
if(id == 2) {
self.select_subactivity.didSelect{(selectedText, index, id) in
//self.Summary_tableView.isHidden = false
self.Summary_tableView.reloadData()
let user_id = UserDefaults.standard.string(forKey: "user_id")!
let url = self.appDelegate.BaseUrl + "woodland/summary"
self.SummaryApi(url: url, userid: user_id, cph_id: cph_id!, subactivity_name: id)
}
}
}
Any help will be highly appreciated!
Upvotes: 0
Views: 402
Reputation: 359
You should remove all the elements from the array upon selection the value from the dropdown and then reload the table
Following Steps should be followed upon selecting a value from the dropDown:
Upvotes: 1
Reputation: 129
viewDidLoad() is called once after the view controller’s view has been loaded into memory. That's why your tableview is not reloading. you should try to call tableview.reloadData() where you are changing the dropdown value.
Upvotes: 0