Close Popover and open new one with one tap

孤街浪徒 提交于 2019-12-04 10:16:14

If you use bar button items in a toolbar, the open popover is not automatically closed when you tap another bar button item. In these situations you should close the visible popover and open the other one in one step.

- (IBAction)sortAction {
[searchBarView resignFirstResponder];
[self.popoverController dismissPopoverAnimated:YES]; //clear popover

self.popoverController = popoverSetting;
[self.popoverController presentPopoverFromBarButtonItem:sortBarButtonItem
                               permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; //show popover
}

hope will help you

Lets say you have 3 buttons and each opens a popup. You could use a state variable that tracks whether a popup is currently open, and inside each "open popup" method, close the existing one (if it is open) before opening the new popup.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!