Commit 4fbfcd1a authored by pete谢兆麟's avatar pete谢兆麟

默认选择YHOtherPickView

parent 9e53dc26
...@@ -467,7 +467,7 @@ class YHItemView: UIView { ...@@ -467,7 +467,7 @@ class YHItemView: UIView {
let window = UIApplication.shared.yhKeyWindow() let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view) window?.addSubview(view)
case .id: case .id:
YHOtherPickerView.show(type: .idType) {[weak self] data in YHOtherPickerView.show(type: .idType, selectTitle: self.dataSource?.message ?? "") {[weak self] data in
guard let self = self else { return } guard let self = self else { return }
self.dataSource?.message = data.title self.dataSource?.message = data.title
self.dataSource?.value = [data.index] self.dataSource?.value = [data.index]
...@@ -487,7 +487,7 @@ class YHItemView: UIView { ...@@ -487,7 +487,7 @@ class YHItemView: UIView {
} }
UIViewController.current?.navigationController?.pushViewController(vc) UIViewController.current?.navigationController?.pushViewController(vc)
case .sex: case .sex:
YHOtherPickerView.show(type: .sex) {[weak self] data in YHOtherPickerView.show(type: .sex, selectTitle: self.dataSource?.message ?? "") {[weak self] data in
guard let self = self else { return } guard let self = self else { return }
self.dataSource?.message = data.title self.dataSource?.message = data.title
self.dataSource?.value = [data.index] self.dataSource?.value = [data.index]
...@@ -497,7 +497,7 @@ class YHItemView: UIView { ...@@ -497,7 +497,7 @@ class YHItemView: UIView {
} }
} }
case .marry: case .marry:
YHOtherPickerView.show(type: .marry) {[weak self] data in YHOtherPickerView.show(type: .marry, selectTitle: self.dataSource?.message ?? "") {[weak self] data in
guard let self = self else { return } guard let self = self else { return }
self.dataSource?.message = data.title self.dataSource?.message = data.title
self.dataSource?.value = [data.index] self.dataSource?.value = [data.index]
......
...@@ -419,7 +419,7 @@ extension YHOtherInfoFillCell { ...@@ -419,7 +419,7 @@ extension YHOtherInfoFillCell {
extension YHOtherInfoFillCell { extension YHOtherInfoFillCell {
@objc func tapViewItem(_ gestureRecognizer: UIPanGestureRecognizer) { @objc func tapViewItem(_ gestureRecognizer: UIPanGestureRecognizer) {
YHOtherPickerView.show(type: .language) { item in YHOtherPickerView.show(type: .language, selectTitle: self.dataModel?.language_detail?.levelDes ?? "") { item in
self.dataModel?.language_detail?.level = Int(item.index) ?? 0 self.dataModel?.language_detail?.level = Int(item.index) ?? 0
self.dataModel?.language_detail?.levelDes = item.title self.dataModel?.language_detail?.levelDes = item.title
self.languageView.updateKeyName(name: "您的语言水平与下列哪一项符合", keyValue:self.dataModel?.language_detail?.levelDes ?? "") self.languageView.updateKeyName(name: "您的语言水平与下列哪一项符合", keyValue:self.dataModel?.language_detail?.levelDes ?? "")
...@@ -429,7 +429,7 @@ extension YHOtherInfoFillCell { ...@@ -429,7 +429,7 @@ extension YHOtherInfoFillCell {
} }
@objc func tapViewItem2(_ gestureRecognizer: UIPanGestureRecognizer) { @objc func tapViewItem2(_ gestureRecognizer: UIPanGestureRecognizer) {
YHOtherPickerView.show(type: .professionalSkill) { item in YHOtherPickerView.show(type: .professionalSkill, selectTitle: self.dataModel?.profession?.optionDes ?? "") { item in
print(item) print(item)
self.dataModel?.profession?.option = Int(item.index) ?? 0 self.dataModel?.profession?.option = Int(item.index) ?? 0
self.dataModel?.profession?.optionDes = item.title self.dataModel?.profession?.optionDes = item.title
......
...@@ -20,6 +20,23 @@ class YHOtherPickerView: UIView { ...@@ -20,6 +20,23 @@ class YHOtherPickerView: UIView {
private var type : YHOtherPickerViewType = .none private var type : YHOtherPickerViewType = .none
var arrData : [YHOtherPickerViewItemData] = [] var arrData : [YHOtherPickerViewItemData] = []
var selectTitle: String = "" {
didSet {
var selectIndex = 0
for i in 0..<arrData.count {
let model = arrData[i]
if model.title == selectTitle {
selectIndex = i
}
if model.index == selectTitle {
selectIndex = i
}
}
pickerView.selectRow(selectIndex, inComponent: 0, animated: false)
userSelectedItem = arrData[selectIndex]
pickerView.reloadAllComponents()
}
}
private var selectBlock:((YHOtherPickerViewItemData)->Void)? //回调 private var selectBlock:((YHOtherPickerViewItemData)->Void)? //回调
private var userSelectedItem : YHOtherPickerViewItemData? //用户选择的item private var userSelectedItem : YHOtherPickerViewItemData? //用户选择的item
...@@ -134,13 +151,14 @@ class YHOtherPickerView: UIView { ...@@ -134,13 +151,14 @@ class YHOtherPickerView: UIView {
UIApplication.shared.yhKeyWindow()?.addSubview(self) UIApplication.shared.yhKeyWindow()?.addSubview(self)
} }
static func show(type:YHOtherPickerViewType, callBack: @escaping ((YHOtherPickerViewItemData)->Void)) { static func show(type:YHOtherPickerViewType, selectTitle: String = "", callBack: @escaping ((YHOtherPickerViewItemData)->Void)) {
IQKeyboardManager.shared.resignFirstResponder() IQKeyboardManager.shared.resignFirstResponder()
let picker = YHOtherPickerView(type: type) let picker = YHOtherPickerView(type: type)
picker.selectBlock = callBack picker.selectBlock = callBack
picker.show() picker.show()
picker.selectTitle = selectTitle
} }
@objc func dismiss() { @objc func dismiss() {
...@@ -154,9 +172,6 @@ class YHOtherPickerView: UIView { ...@@ -154,9 +172,6 @@ class YHOtherPickerView: UIView {
whiteContentView.addSubview(topView) whiteContentView.addSubview(topView)
whiteContentView.addSubview(pickerView) whiteContentView.addSubview(pickerView)
if let title = title { if let title = title {
titleLabel.text = title titleLabel.text = title
} else { } else {
......
...@@ -448,7 +448,7 @@ class YHWorkExperienceItemView: UIView { ...@@ -448,7 +448,7 @@ class YHWorkExperienceItemView: UIView {
} }
UIViewController.current?.navigationController?.pushViewController(vc) UIViewController.current?.navigationController?.pushViewController(vc)
case .nature: case .nature:
YHOtherPickerView.show(type: .nature) {[weak self] data in YHOtherPickerView.show(type: .nature, selectTitle: self.dataSource?.message ?? "") {[weak self] data in
guard let self = self else { return } guard let self = self else { return }
self.dataSource?.message = data.title self.dataSource?.message = data.title
self.updateAllViews() self.updateAllViews()
...@@ -457,7 +457,7 @@ class YHWorkExperienceItemView: UIView { ...@@ -457,7 +457,7 @@ class YHWorkExperienceItemView: UIView {
} }
} }
case .certificate: case .certificate:
YHOtherPickerView.show(type: .certificate) {[weak self] data in YHOtherPickerView.show(type: .certificate, selectTitle: self.dataSource?.message ?? "") {[weak self] data in
guard let self = self else { return } guard let self = self else { return }
self.dataSource?.message = data.title self.dataSource?.message = data.title
self.updateAllViews() self.updateAllViews()
...@@ -466,7 +466,7 @@ class YHWorkExperienceItemView: UIView { ...@@ -466,7 +466,7 @@ class YHWorkExperienceItemView: UIView {
} }
} }
case .structure: case .structure:
YHOtherPickerView.show(type: .structure) {[weak self] data in YHOtherPickerView.show(type: .structure, selectTitle: self.dataSource?.message ?? "") {[weak self] data in
guard let self = self else { return } guard let self = self else { return }
self.dataSource?.message = data.title self.dataSource?.message = data.title
self.dataSource?.value = [data.index] self.dataSource?.value = [data.index]
...@@ -476,7 +476,7 @@ class YHWorkExperienceItemView: UIView { ...@@ -476,7 +476,7 @@ class YHWorkExperienceItemView: UIView {
} }
} }
case .level: case .level:
YHOtherPickerView.show(type: .level) {[weak self] data in YHOtherPickerView.show(type: .level, selectTitle: self.dataSource?.message ?? "") {[weak self] data in
guard let self = self else { return } guard let self = self else { return }
self.dataSource?.message = data.title self.dataSource?.message = data.title
self.dataSource?.value = [data.index] self.dataSource?.value = [data.index]
...@@ -486,7 +486,7 @@ class YHWorkExperienceItemView: UIView { ...@@ -486,7 +486,7 @@ class YHWorkExperienceItemView: UIView {
} }
} }
case .prove: case .prove:
YHOtherPickerView.show(type: .prove) {[weak self] data in YHOtherPickerView.show(type: .prove, selectTitle: self.dataSource?.message ?? "") {[weak self] data in
guard let self = self else { return } guard let self = self else { return }
self.dataSource?.message = data.title self.dataSource?.message = data.title
self.updateAllViews() self.updateAllViews()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment