0

I've view controller class in that i've collection view, search bar and drop down button. Drop down button is a(Ex:- @IBOutlet weak var dropDownMenuTwo: DropMenuButton!) DropMenuButton class. DropMenuButton.swift (Ex:- class DropMenuButton: UIButton, UITableViewDelegate, UITableViewDataSource {}) class contains tableview view in that i'm showing all sorting technquies. If i select any sorting from drop down button i will get tableview indexpath.row value in didselectitematindexpath. I want to update collection in viewcontroller immediately how is it possible. Plese help me. enter image description here Drop down is a subclass of DropMenuButton class. When value changes in this class i want to update collection reload in viewcontroller how can i handle this.

enter image description here

rmaddy
  • 314,917
  • 42
  • 532
  • 579
iOSDude
  • 274
  • 2
  • 25
  • collectionview.reloaddata in didselectrow at indexpath. – Muhammed Azharudheen Aug 15 '18 at 08:52
  • didselectrow is on other empty swift file of UIbuttion. Class is ---->DropMenuButton.swift and inside of this class is Like ---> class DropMenuButton: UIButton, UITableViewDelegate, UITableViewDataSource { Here all tableview methods are implemented }. Collection view is implemented on other view controller class. i want to reload Here in tableview didselect how it is possible. – iOSDude Aug 15 '18 at 12:39

1 Answers1

0

There are multiple way to do so. 1. You can add delegate from 'TableViewdidSelect' class to collection view implementation class. (How to add Delegates in swift??) 2. Other way is to add 'Callback'. (How to add Callback function syntax in Swift?)

  • One is View controller in that (**@IBOutlet weak var dropDownMenuTwo: DropMenuButton! **) and Other one is a class of type UIButton like (**class DropMenuButton: UIButton, UITableViewDelegate, UITableViewDataSource { Here tableview methods are implemented}**) this is another swift file (**DropMenuButton.swift**). When i select any sort it will update in didselectrow method there i need to reload collection view present in viewcontroller please let me know how can i achieve it thanks. – iOSDude Aug 15 '18 at 12:51