带有SWRevealViewController的Pulley的委托方法未得到调用

时间:2019-02-26 12:00:03

标签: swift swrevealviewcontroller

我正在使用SWReveal https://github.com/John-Lluch/SWRevealViewController库来创建侧面菜单应用程序。在主视图控制器中,我有一个mapview,在mapview中,我实现了一个工作正常的底页https://github.com/52inc/Pulley/。然后,我继续将前视图控制器设置为class BottomSheetVC: PulleyViewController { weak var infoVc: InfoVC! weak var estimateVc: EstimateVC! weak var serviceUnavailableVc: ServiceUnavailableVC! weak var onTripVc: OnTripVC! weak private var currentViewController: UIViewController? { didSet { if let onTripVc = oldValue as? OnTripVC { // Reset the view if it was showing the cancellation reason view. // This ensures the cancellation view is not the initial view next time // this bottom sheet is shown. onTripVc.setSecondViewVisible(false) } if let currentViewController = currentViewController { setDrawerContentViewController(controller: currentViewController, animated: false) setNeedsSupportedDrawerPositionsUpdate() } } } var mode = BottomSheetMode.info { didSet { switch mode { case .info: currentViewController = infoVc case .estimate: currentViewController = estimateVc case .serviceUnavailable: currentViewController = serviceUnavailableVc case .onTrip: currentViewController = onTripVc } } } } ,我有一个faButton位于mapView的底部,当调整底层时,该fabButton应该重新调整并向上移动,但我无法去做。我已经尝试解决此问题好几天了,但尚未做出回应。以下是我的代码,可以根据要求添加任何内容

...
class ServiceUnavailableVC: BaseBottomSheetVC {
    override var mode: BottomSheetMode {
        return .serviceUnavailable
    }
}

class BaseBottomSheetVC: UIViewController, PulleyDrawerViewControllerDelegate {
    var mode: BottomSheetMode {
        return .onTrip
    }

    func collapsedDrawerHeight(bottomSafeArea: CGFloat) -> CGFloat {
        return mode.collapsedDrawerHeight
    }

    func partialRevealDrawerHeight(bottomSafeArea: CGFloat) -> CGFloat {
        return mode.partialRevealDrawerHeight
    }

    func supportedDrawerPositions() -> [PulleyPosition] {
        return mode.supportedDrawerPositions
    }
}


// MARK: - PulleyPrimaryContentControllerDelegate
extension HomeVC: PulleyPrimaryContentControllerDelegate {
    func drawerPositionDidChange(drawer: PulleyViewController, bottomSafeArea: CGFloat) {
        guard let drawer = drawer as? BottomSheetVC else { return }
        switch drawer.drawerPosition {
        case .closed:
            if drawer.mode == .estimate {
                self.toggleButton.image = Icon.arrowBack
            }
        case .collapsed:
            if drawer.mode == .estimate {
                self.toggleButton.image = Icon.close
            }
        default: break
        }
    }

    func makeUIAdjustmentsForFullscreen(progress: CGFloat, bottomSafeArea: CGFloat) {

    }

    func drawerChangedDistanceFromBottom(drawer: PulleyViewController, distance: CGFloat,
                                         bottomSafeArea: CGFloat) {

        print("DRAWER DISPLAY")
        guard let drawer = drawer as? BottomSheetVC else { return }
        print("DRAWER DISPLAY \(drawer.currentDisplayMode)")
        let distance = distance - bottomSafeArea
        if drawer.mode == .estimate || drawer.mode == .onTrip {
            mapView.padding = UIEdgeInsets(top: 20, left: 0, bottom: distance, right: 20)
        }
        else if drawer.mode == .info {
            // This fixes a bug where the bottom padding added to the map when the promo bottom
            // sheet is visible causes the map pin to be off the center of the map. To fix this,
            // add padding to the top and bottom of the map.
            mapView.padding = UIEdgeInsets(top: distance, left: 0, bottom: distance, right: 20)
        }
        else {
            mapView.padding = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
        }
        fabBottomConstraint.constant = distance + 16
    }
}

SheetContent.swift

let storyboard = R.storyboard.baseSB()

            let swVC = storyboard.instantiateViewController(withIdentifier: SWRevealViewController.className) as! SWRevealViewController

            swVC.loadView()

            let homeVC = swVC.frontViewController as! HomeVC

            homeVC.mode = AppMode.go
            let bottomSheetVC = BottomSheetVC(contentViewController: swVC, drawerViewController: UIViewController())
            bottomSheetVC.drawerCornerRadius = 0
            bottomSheetVC.initialDrawerPosition = .closed
            bottomSheetVC.shadowRadius = 0
            bottomSheetVC.shadowOpacity = 0

            homeVC.bottomDrawer = bottomSheetVC
            bottomSheetVC.modalTransitionStyle = .crossDissolve

            self?.present(bottomSheetVC, animated: true, completion: nil)

我如何启动Bottom Viewcontroller

onDidReceiveNotification

0 个答案:

没有答案