GithubHelp home page GithubHelp logo

marioiannotta / splitviewdraganddrop Goto Github PK

View Code? Open in Web Editor NEW
329.0 13.0 21.0 2.03 MB

Drag and drop between your apps in split view mode on iOS 9

License: MIT License

Swift 100.00%
drag-and-drop swift ipad multitasking split-view

splitviewdraganddrop's Introduction

SplitViewDragAndDrop

Easily add drag and drop to pass data between your apps

Platform Swift 3 Cocoapods Compatible

Setup

  • Add pod 'SplitViewDragAndDrop' to your Podfile or copy the "SplitViewDragAndDrop" folder into your project
  • Make sure to call SplitViewDragAndDrop.configure(groupIdentifier: <YOUR-APP-GROUP-ID>) in application:didFinishLaunchingWithOptions:. Your apps must share that app group in order to communicate.
  • Configure the view you want to drag with SplitViewDragAndDrop.handleDrag(viewToDrag: <THE-DRAGGABLE-VIEW>, identifier: <AN-IDENTIFIER>, dataToTransfer: <SOME-DATA-TO-TRANSFER>) where
    • viewToDrag is a UIView and it will be snapshotted and dragged around
    • identifier is a string rappresenting an unique identifier.
    • dataToTransfer is a Data, it could be an image, a pdf ecc..
  • Configure the drop observer with
    SplitViewDragAndDrop.addDropObserver(
     targetView: <A-TARGET-VIEW>,
     identifier: <AN-IDENTIFIER>,
     draggingBegan: { frame, draggedViewSnapshotImage, dataTransfered in
       // the drag is began, here you can perform some ui changes in order to tell the user where to drag the item
     },
     draggingValidation: { frame, draggedViewSnapshotImage, dataTransfered in            
       return <A-BOOL>
     },
     completion: { frame, draggedViewSnapshotImage, dataTransfered, isValid in
       // the drag is complete and you can use dataTrasfered if you want
     }
    )
    
    where
    • targetView is a UIView and it will be the center of the dragged item when the user end the dragging and the validation succedded
    • identifier is a string rappresenting an unique identifier
    • draggingBegan is a closure that will be called when the drag is began
    • draggingValidation is a closure that will be called when the drag is ended. You have to return a value that indicate if the drag is valid or not. If that value is true, the dragged view will be moved to the center of the targetView, otherwise it will be moved back to it's original position.
    • completion is a closure that will be called after the validation.

Demo

In this repository you can also find a demo.

Info

If you like this git you can follow me here or on twitter :) @MarioIannotta

Cheers from Italy!

splitviewdraganddrop's People

Contributors

marioiannotta 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  avatar  avatar  avatar  avatar  avatar  avatar

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.