Giter Site home page Giter Site logo

kuipopover's Introduction

KUIPopOver

Swift CocoaPods Carthage compatible

  • Easy to use PopOver in iOS (iPhone, iPad)

alt tag

Requirements

Installation

CocoaPods

KUIPopOver is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'KUIPopOver'

Carthage

For iOS 8+ projects with Carthage

github "Kofktu/KUIPopOver"

Usage

Before

let popOverViewController = DefaultPopOverViewController()
popOverViewController.preferredContentSize = CGSize(width: 200.0, height: 300.0)
popOverViewController.popoverPresentationController?.sourceView = sender

let customView = CustomPopOverView(frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: 200.0, height: 300.0)))
popOverViewController.view.addSubview(customView)
popOverViewController.popoverPresentationController?.sourceRect = sender.bounds
present(popOverViewController, animated: true, completion: nil)

KUIPopOverUsable

public protocol KUIPopOverUsable {
    var contentSize: CGSize { get }
    var contentView: UIView { get }
    var popOverBackgroundColor: UIColor? { get }
    var arrowDirection: UIPopoverArrowDirection { get }
}

UIView

public func showPopover(sourceView: UIView, sourceRect: CGRect?, completion: ShowPopoverCompletion?)
public func showPopover(barButtonItem: UIBarButtonItem, completion: ShowPopoverCompletion?)
public func dismissPopover(animated: Bool, completion: DismissPopoverCompletion?)

UIViewController

public func showPopover(sourceView: UIView, sourceRect: CGRect?, completion: ShowPopoverCompletion?)
public func showPopoverWithNavigationController(sourceView: UIView, sourceRect: CGRect?, completion: ShowPopoverCompletion?)
public func showPopover(barButtonItem: UIBarButtonItem, completion: ShowPopoverCompletion?)
public func showPopoverWithNavigationController(barButtonItem: UIBarButtonItem, completion: ShowPopoverCompletion?)
public func dismissPopover(animated: Bool, completion: DismissPopoverCompletion?)

At a Glance

UIView

class CustomView: UIView, KUIPopOverUsable {
    // The default size is the size of the view, and you can override it if you want to customize it.
    var contentSize: CGSize {
    	return Size
    }
}

let view = CustomView()
view.showPopover(barButtonItem: sender)
view.dismissPopover(animated: true)
view.dismissPopover(animated: true, completion: {
})

UIViewController

class CustomViewController: UIViewController, KUIPopOverUsable {
    var contentSize: CGSize {
        // PopOver preferredContentSize
    }
}

let customViewController = CustomViewController()

// from senderView
customViewController.showPopover(sourceView: sender, sourceRect: sender.bounds)

// from barButtonItem
customViewController.showPopover(barButtonItem: sender)

// with NavigationController
customViewController.showPopoverWithNavigationController(sourceView: sender, sourceRect: sender.bounds)

customViewController.dismissPopover(animated: true)
customViewController.dismissPopover(animated: true, completion: {
})

Authors

Taeun Kim (kofktu), [email protected]

License

KUIPopOver is available under the MIT license. See the LICENSE file for more info.

kuipopover's People

Contributors

cozzin avatar kofktu avatar lumyk avatar mshibanami avatar radvansky-tomas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

kuipopover's Issues

Dismissing popover on command

Popover seems to dismiss fine when using code such as:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let filterVC = storyboard.instantiateViewController(
            withIdentifier: "filterViewController") as! FilterViewController
DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) {
            filterVC.dismissPopover(animated: true, completion: {
                print("CustomPopOverViewController.dismiss.completion")
            })
        }

However when trying to call it directly i.e.

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let filterVC = storyboard.instantiateViewController(
            withIdentifier: "filterViewController") as! FilterViewController
filterVC.dismissPopover(animated: false)

There is no action. Any ideas where I am going wrong? Thank you

Change arrow position

Hi,

Would it be possible to add another enum to change the position of the arrow. Right now if I mention UIPopoverArrowDirection as .right, it appears on the middle right side of the view. In certain screens, I would either need it at the right top or right bottom.

Would be great if this addition could be done.

Thanks!

assigning delegate?

The area that the repo seems to be missing entirely is the ability to easily use the repo and assign "self" to the popover to handle the proper workflow of actually using the popover's reason for being show. Perhaps I have a preset notion of what I am seeking that is keeping me from seeing the answer.

I searched "delegate" in the issues and found nary a mention, so thought to ask. thx.

Fill UITableView??

Anyway to populate a table (pass values? completion?) after the popover has been presented?

Visibility of navbar in popover not accounted for.

Minor note: some popovers (for example the first in a chain), may not display the navbar. Flipping back to such a popover results in an alteration of height 44 under the original height. A tad confusing to track.

Using popped-up viewController as local property leads to error

Here is my test project.

I use a viewController as a local property(to keep some info when it is opened again). But if I click the trigger button very fast. An error happens:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modal view controller on itself. Presenting controller is <testPopup.TipViewController: 0x103c12e40>.'

Test project is here.

testPopup.zip

Can I hide the arrow?

Thanks for the great project.

Can I hide the arrow? Just show the custom view is good for me.

Transparent background for popover

Hey! Quick question, do you know how can I set a semi transparent background to the popover?

I need to accomplish something like this.

Screen Shot 2020-03-27 at 16 33 21

Thanks!

SPM support

hi,
can you add the support to swift package manager??

thank

Completion handler being called immediately...

You can see this in the demo, by breaking any of the completion handlers and running the example. You can seem them called immediately, which great negates the ease-of-use factor if collecting info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.