Refactoring the code to calculate the frame of popover.
Added the code to decide the direction  of the popover automatically.
Refactoring.
Refactoring the code to calculate area of popover.