[SWIFT] Difference between addPanel and presentModally of FloatingPanel

FloatingPanel https://github.com/SCENEE/FloatingPanel#add-a-floating-panel-as-a-child-view-controller

Add a floating panel as a child view controller

When added as a child VC, it is basically assumed that it will not be deleted by swiping down. If you write fpc.isRemovalInteractionEnabled = true here, the parent view on the back will scroll when scrolling, or if you close it with a down swipe, the parent view button will not work and you will not be able to open the floating panel again. ..

Present a floating panel as a modality

So basically, it's better to use this which is the standard behavior of iOS and close it with a down swipe.

import FloatingPanel

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
		fpc = FloatingPanelController(delegate: self)
		fpc.layout = MyFloatingPanelLayout()
        let contentVC == CommentViewController()
		// or let contentVC = CommentViewController.fromStoryboard()
		fpc.set(contentViewController: contentVC)
		fpc.isRemovalInteractionEnabled = true // Let it removable by a swipe-down
		fpc.track(scrollView: contentVC.tableView) // .Make the contentVC tableView scrollable when it becomes full
	}

    @IBAction func didTapCommentButton(_ sender: Any) {
		self.present(fpc, animated: true, completion: nil)
	}
		
}

class MyFloatingPanelLayout: FloatingPanelLayout {
	let position: FloatingPanelPosition = .bottom
	let initialState: FloatingPanelState = .half
    var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] {
        return [
            .half: FloatingPanelLayoutAnchor(fractionalInset: 0.5, edge: .bottom, referenceGuide: .safeArea),
        ]
    }
}

If you use addPanel

At first, hide it with let initialState = .hidden, and when the button is pressed, call the following from the bottom.

self.fpc.move(to: .half, animated: true)

It should be a code that hides in the following form when you press the close button (I prepared it instead because it can not be closed by swiping down).

self.fpc.move(to: .hide, animated: true)

Recommended Posts

Difference between addPanel and presentModally of FloatingPanel
Difference between isEmpty and isBlank of StringUtils
Difference between vh and%
Difference between i ++ and ++ i
Difference between member and collection of rails routes.rb
Difference between product and variant
Difference between redirect_to and render
Rails: Difference between resources and resources
Difference between puts and print
Difference between redirect_to and render
Difference between CUI and GUI
Difference between mockito-core and mockito-all
Difference between class and instance
Difference between bundle and bundle install
Difference between ArrayList and LinkedList
Difference between render and redirect_to
Difference between List and ArrayList
Difference between .bashrc and .bash_profile
Difference between StringBuilder and StringBuffer
Difference between render and redirect_to
Difference between render and redirect_to
[Docker-compose] Difference between env_file and environment. Priority of environment variable application
[Ruby] About the difference between 2 dots and 3 dots of range object.
[Java] Difference between assignment of basic type variable and assignment of reference type variable
[Java] Difference between Stack Overflow Error and Out Of Memory Error
[Ruby] Difference between get and post
Difference between instance method and class method
Difference between render method and redirect_to
Difference between interface and abstract class
[Java] Difference between Hashmap and HashTable
[Terminal] Difference between irb and pry
JavaServlet: Difference between executeQuery and executeUpdate
[Ruby] Difference between is_a? And instance_of?
Difference between == operator and eqals method
Rough difference between RSpec and minitest
[Rails] Difference between find and find_by
Understand the difference between each_with_index and each.with_index
Difference between instance variable and class variable
[JAVA] Difference between abstract and interface
Difference between Stream map and flatMap
[Java] Difference between array and ArrayList
Difference between primitive type and reference type
Difference between string.getByte () and Hex.decodeHex (string.toCharaArray ())
[Java] Difference between Closeable and AutoCloseable
[Java] Difference between StringBuffer and StringBuilder
[Java] Difference between length, length () and size ()
[rails] Difference between redirect_to and render
[Android] Difference between finish (); and return;
Difference between byCharWrapping and byWordWrapping of UI Label in Japanese display
Difference between final and Immutable in Java
[Memo] Difference between bundle install and update
Difference between Ruby instance variable and local variable
Difference between pop () and peek () in stack
Differences between preface and postfix of operators
[For beginners] Difference between Java and Kotlin
Difference between getText () and getAttribute () in Selenium
Difference between "|| =" and "instance_variable_defined?" In Ruby memoization
Difference between EMPTY_ELEMENTDATA and DEFAULTCAPACITY_EMPTY_ELEMENTDATA in ArrayList
[Ruby] Difference between print, puts and p
[Java] Difference between Intstream range and rangeClosed
Difference between int and Integer in Java