Hassan-Aftab / HADropDown

iOS Control for Drop Down Menu
Other
58 stars 8 forks source link

DropDown views does not get removed #9

Closed arpitjain03 closed 6 years ago

arpitjain03 commented 6 years ago

If I navigate to another controller, from the controller in which HADropDown is used it does not get removed. May be this is because of adding it on window. Even dropDown.removeFromSuperview() does n't work. Help me in the same. Thanks in advance.

Sahilberi commented 6 years ago

Hi @arpitjain03, we are removing topmost view in collapseTableView func. so, I guess this problem shouldn't occur. can you debug is this function is calling or not?

func collapseTableView() {

if isCollapsed {
  UIView.animate(withDuration: 0.25, animations: {
    self.table.frame = CGRect(x: self.tableFrame.origin.x, y: 
    self.tableFrame.origin.y+self.frame.height, width: self.frame.width, height: 0)
  })

  var rootView = self.superview
  while rootView?.superview != nil {
    rootView = rootView?.superview
  }

  rootView?.viewWithTag(99121)?.removeFromSuperview()

  if delegate != nil {
    delegate.didHide(dropDown: self)
  }
}

} }

arpitjain03 commented 6 years ago

It gets called but the view doesn't get removed. After this If i select any row it gets disappeared

Sahilberi commented 6 years ago

Can you show the code where are navigating to another controller? I mean if you tap outside the table view, tableview should collapse.

arpitjain03 commented 6 years ago

Yeah you are right if i tap outside the tableview it collapse. But my case is i opened the drop down and clicked on a button which navigates me to next screen. Then the dropdown still remains there. I navigated using : self.navigationController?.pushViewController(viewController!,animated: true)

Sahilberi commented 6 years ago

Which button you are tapping ? can you share screenshots? I mean if HADropDown shows it will show in topmost view. so, there should be no button. Ideally, you can click on three views: