azharashiq178 / FAPopover

Single Popover manager for iPhone & iPad devices (Portrait + Landscape)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alt text

Swift version License Platform

Benefits

  • Single library to show popovers in both iPhones & iPads
  • One line usage with easy integration
  • Works on iPhone portrait and landscape mode as well

Installation

Swift Package Manager

Right now FAPopover is only supported via swift package manager. You can also install it manually. Just drag source folder files into your project and you're all set.

Usage (2 Steps)

Step 1

Conform the controller with PopoverPresentable protocol and provide CGSize for the controller

Step 2

In viewWillAppear set the preferredContentSize = preferredContentsizeForPopover()

Step for setting size of navigation controller

In viewWillAppear set the navigationController?.preferredContentSize = preferredContentsizeForPopover()

Examples

Following are some examples of how you can use FAPopoverManager,

Case 1 (Simple)

@IBAction func showSingleControllerInPopover(_ sender: UIButton) {
    
    let testViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(identifier: "TestTableViewController")
    FAPopoverManager.show(testViewController, arrow: .up, sourceRect: sender.bounds, sourceView: sender)
}

Case 2 (Navigation)

@IBAction func showNavigationalPopover(_ sender: UIButton) {
    
    let testViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(identifier: "TestTableViewController")
    let navigationController = UINavigationController(rootViewController: testViewController)
    FAPopoverManager.show(navigationController, arrow: .up, sourceRect: sender.bounds, sourceView: sender)
}

Case 3 (UIBarButtonItem + Navigation)

@IBAction func showSingleControllerInFromUIBarButtonItem(_ sender: UIBarButtonItem) {
    
    let testViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(identifier: "TestTableViewController")
    let navigationController = UINavigationController(rootViewController: testViewController)

    FAPopoverManager.showFromBarButtonItem(navigationController, arrow: .up, sourceView: sender)
}

Supports interface rotation

License

InteractiveView is licensed under MIT.

For more details visit the LICENSE file for more info.

Author

Fahid Attique - (https://github.com/fahidattique55)

About

Single Popover manager for iPhone & iPad devices (Portrait + Landscape)

License:MIT License


Languages

Language:Swift 100.0%