将自定义推送行迁移到Eureka 4.1

时间:2018-03-27 19:45:49

标签: eureka-forms

我很难将自定义行从以前版本的Eureka(大约3.0)迁移到Eureka 4.1。自定义行是自定义推送行,因此标签可以有多行,因此推送的视图控制器可以具有自定义节标题。可能有一种更好的方法来实现这一点,而不是拥有自定义行,这是一种可能的解决方案,但我不确定这是否可能。

所以有两个问题:自定义行和自定义选择器视图控制器。这是自定义行:

open class _StackedPushRow: SelectorRow<StackedPushCell, CustomSelectorViewController<String>> {

    public typealias StackedRow = PushRow<String>

    var dontClearWhenDisabled: Bool = false

    required public init(tag: String?) {
        super.init(tag: tag)
        cellProvider = CellProvider(nibName: "StackedPushCell")

        presentationMode = .show(controllerProvider: ControllerProvider.callback {
            return CustomSelectorViewController<Cell.Value> { _ in } },
         onDismiss: { vc in
            self.cell.update()
            _ = vc.navigationController?.popViewController(animated: true)
        })
    }
}

/// A generic inline row where the user can pick an option from a presented view controller
public final class StackedPushRow: _StackedPushRow, RowType {

    required public init(tag: String?) {
        super.init(tag: tag)
    }

}

这里是自定义选择器视图控制器:

public final class CustomSelectorViewController<T: Equatable>: SelectorViewController<T> {

    open override func viewDidLoad() {
        super.viewDidLoad()

        form.first?.header = HeaderFooterView.caliberStyleSectionHeader(title: row.title ?? "")
    }

    static func presentationMode<T: Equatable>() -> PresentationMode<SelectorViewController<T>> {
        return .show(controllerProvider: ControllerProvider.callback {
            return CustomSelectorViewController<T> { _ in }
        }, onDismiss: { vc in
            _ = vc.navigationController?.popViewController(animated: true)
        })
    }
}

以下是自定义行的错误:

  

/Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomRows/StackedPushRow.swift:78:29:   通用类型&#39; SelectorRow&#39;专门有太多的类型参数   (得到2,但预计1)

     

/Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomRows/StackedPushRow.swift:85:9:   &#39;超&#39;成员不能在根类中引用   /Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomRows/StackedPushRow.swift:86:9:   使用未解析的标识符&#39; cellProvider&#39;   /Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomRows/StackedPushRow.swift:88:9:   使用未解析的标识符&presentation 39&#39;   /Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomRows/StackedPushRow.swift:98:20:   输入&#39; StackedPushRow&#39;不符合协议&#39; BaseRowType&#39;   /Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomRows/StackedPushRow.swift:98:20:   输入&#39; StackedPushRow&#39;不符合协议&#39; RowType&#39;   /Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomRows/StackedPushRow.swift:98:20:   候选人具有非匹配类型&#39;(String?,(Self) - &gt; Void)&#39;   (Eureka.RowType)   /Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomRows/StackedPushRow.swift:98:20:   输入&#39; StackedPushRow&#39;不符合协议&#39; Taggable&#39;   /Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomRows/StackedPushRow.swift:98:20:   输入&#39; StackedPushRow&#39;不符合协议&#39; TypedRowType&#39;   /Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomRows/StackedPushRow.swift:111:9:   使用未解析的标识符&#39; validationOptions&#39;   /Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomRows/StackedPushRow.swift:141:9:   &#39; StackedPushRow&#39;不是&#39; BaseRow&#39;

的子类型

以下是自定义选择器视图控制器的错误:

  

/Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomSelectorViewController.swift:12:64:   输入&#39; T&#39;不符合协议&#39; OptionsProviderRow&#39;   /Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomSelectorViewController.swift:14:24:   方法不会覆盖其超类中的任何方法   /Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomSelectorViewController.swift:15:9:   &#39;超&#39;成员不能在根类中引用   /Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomSelectorViewController.swift:17:9:   使用未解析的标识符&#39;形式&#39;   /Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomSelectorViewController.swift:17:80:   使用未解析的标识符&#39; row&#39;   /Users/rod/Documents/Development/Caliber/CaliberiOS/H2O/_iOS/H2O/UI/Common/CustomSelectorViewController.swift:22:52:   传递给不带参数的调用的参数

我已经阅读了关于Github的问题部分并看到了其他人遇到的例子,但每当我尝试将这些例子付诸实践时,我遇到了其他问题,我只是继续在圈子里跑。我真的可以使用一些帮助。

感谢。

1 个答案:

答案 0 :(得分:0)

SelectorRow现在只采用通用的Cell类型,但没有视图控制器。 SelectorViewController由presentationMode定义。你应该声明你的行: open class _StackedPushRow: SelectorRow<StackedPushCell>

对于您的CustomSelectorViewController,您需要传递您将用作通用类型的rowType。该行类型必须符合OptionsProviderRow,例如ListCheckRow。