I need to create a new popover view as the anchor is not visible in Interface Builder during compile time.
According to this post, implementing the delegate method will
It seems moving the line presentViewController(contentView, animated: true, completion: nil) to the end of the function would fix the issue.
presentViewController(contentView, animated: true, completion: nil)