I would like to navigate from VC1 (All Restaurant View) to VC2 (Restaurant Details View) and when ill press "Back Button" it shouldn't reload VC1 again.
How can I solve this?
func clickNameButtonCollectionView(sender: UIButton) {
let restaurent_Id = ((self.allRecommendedRestaurent[sender.tag] as AnyObject).value(forKey: "id") as AnyObject) as? Int
let obj = self.storyboard?.instantiateViewController(withIdentifier: "ResturantDetailsController") as! ResturantDetailsController
obj.restaurent_ID = restaurent_Id!
self.navigationController?.pushViewController(obj, animated: true)
}
@IBAction func backPressed(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
Added:
override func viewDidLoad() {
super.viewDidLoad()
self.refreshControl.addTarget(self, action: #selector(self.reloadJoinedData), for: UIControlEvents.valueChanged)
self.mainScrollView?.addSubview(refreshControl)
self.appDel.apiManager.setCurrentViewController(vc: self)
// Do any additional setup after loading the view.
resturantTable.delegate = self
resturantTable.dataSource = self
resturantTable.bounces = false
resturantcollection.delegate = self
resturantcollection.dataSource = self
resturantcollection.bounces = false
You can use block to perform any action after back button press. Follow below code
1) Create block in your
ResturantDetailsController
2) Update your back button action
backPressed
3) Now in VC1 when you create
ResturantDetailsController
object.Please write this code in
viewWillAppear
method in VC1 class:It may helps you.Thank you.
If you are using
UITableView
in VC1 then reload it inviewWillAppear
then you will get updated or this is you refresh your list