Search code examples
swiftswift2popoveruitableview

Popover position incorrect in tableviewcell button


When running my popover, the code is displayed at the top left instead of displaying in the same position of the clicked icon, is there something I can change to correct the position?

enter image description here

enter image description here


Solution

  • This is because you had set your aView's CGRect to both x and y to 0.

    If you are doing it programatically, you might have to know the position where you want your view to be, or you can even set like below, to make your view start at most right of your screen (X = 0), and same row with your button's Y

    CGRect(x:0 ,y: yourButton.frame.minY , width:self.view.frame.width,height:180)