-
Notifications
You must be signed in to change notification settings - Fork 0
/
AlwaysPresentAsPopover.swift
31 lines (25 loc) · 1.04 KB
/
AlwaysPresentAsPopover.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
// AlwaysPresentAsPopover.swift
// StoryboardSnippets
//
// Created by Elliott Io on 4/26/20.
// Copyright © 2020 elliott io. All rights reserved.
//
import Foundation
import UIKit
class AlwaysPresentAsPopover : NSObject, UIPopoverPresentationControllerDelegate {
// `sharedInstance` because the delegate property is weak - the delegate instance needs to be retained.
private static let sharedInstance = AlwaysPresentAsPopover()
private override init() {
super.init()
}
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}
static func configurePresentation(forController controller : UIViewController) -> UIPopoverPresentationController {
controller.modalPresentationStyle = .popover
let presentationController = controller.presentationController as! UIPopoverPresentationController
presentationController.delegate = AlwaysPresentAsPopover.sharedInstance
return presentationController
}
}