From 5e7aa97ca1fdcd00052305788b79b1a0278179fb Mon Sep 17 00:00:00 2001 From: tichise Date: Tue, 17 Sep 2019 14:44:26 +0900 Subject: [PATCH 1/5] update version --- PopOverMenu.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PopOverMenu.podspec b/PopOverMenu.podspec index 517af27..dd9c85d 100644 --- a/PopOverMenu.podspec +++ b/PopOverMenu.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'PopOverMenu' - s.version = '2.5.3' + s.version = '2.5.4' s.license = 'MIT' s.summary = 'PopOverMenu is a PopOver style menu.' s.homepage = 'https://github.com/tichise/PopOverMenu' From 75dfaa370dd9e69d1abaed3359ae7b6ae46290c6 Mon Sep 17 00:00:00 2001 From: tichise Date: Tue, 17 Sep 2019 14:45:11 +0900 Subject: [PATCH 2/5] add argument for separatorStyle --- Sample/Sample/RootViewController.swift | 12 +++++++----- Sample/Sample/SampleViewController.swift | 4 +++- Sources/PopOverViewController+Array.swift | 9 ++++----- Sources/PopOverViewController+Enum.swift | 8 ++++---- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Sample/Sample/RootViewController.swift b/Sample/Sample/RootViewController.swift index 1ec5830..55e1518 100644 --- a/Sample/Sample/RootViewController.swift +++ b/Sample/Sample/RootViewController.swift @@ -8,6 +8,8 @@ import PopOverMenu class RootViewController: UITableViewController, UIAdaptivePresentationControllerDelegate { + let separatorStyle: UITableViewCell.SeparatorStyle = .none + var popOverViewController: PopOverViewController? var section1 = ["Int Array", "String Array", "Int Array(All selectable)"] var section2 = ["Enum", "Enum(All selectable)"] @@ -102,7 +104,7 @@ class RootViewController: UITableViewController, UIAdaptivePresentationControlle let titles = [ "Menu1", "Menu2", "Menu3"] let keys = [1, 2, 3] - self.popOverViewController?.setArrayForView(delegate: self, view: view, titles: titles, keys: keys, defaultKey: selectedIntKey) { (key, index) in + self.popOverViewController?.setArrayForView(delegate: self, view: view, titles: titles, keys: keys, defaultKey: selectedIntKey, separatorStyle: separatorStyle) { (key, index) in self.selectedIntKey = key @@ -120,7 +122,7 @@ class RootViewController: UITableViewController, UIAdaptivePresentationControlle let titles = [ "Menu1", "Menu2", "Menu3"] let keys = ["menu1", "menu2", "menu3"] - self.popOverViewController?.setArrayForView(delegate: self, view: view, titles: titles, keys: keys, defaultKey: selectedStringKey) { (key, index) in + self.popOverViewController?.setArrayForView(delegate: self, view: view, titles: titles, keys: keys, defaultKey: selectedStringKey, separatorStyle: separatorStyle) { (key, index) in self.selectedStringKey = key @@ -138,7 +140,7 @@ class RootViewController: UITableViewController, UIAdaptivePresentationControlle let titles = ["Menu1", "Menu2", "Menu3"] let keys = [1, 2, 3] - self.popOverViewController?.setArrayForView(delegate: self, view: view, titles: titles, keys: keys, defaultKey: selectedIntKey, allName: allName, onSelected: { (key, index) in + self.popOverViewController?.setArrayForView(delegate: self, view: view, titles: titles, keys: keys, defaultKey: selectedIntKey, allName: allName, separatorStyle: separatorStyle, onSelected: { (key, index) in self.selectedIntKey = key print("key is \(String(describing: key)) , index is \(index) ") @@ -154,7 +156,7 @@ class RootViewController: UITableViewController, UIAdaptivePresentationControlle func openEnumMenu(view :UIView) { self.popOverViewController = PopOverViewController.instantiate() - self.popOverViewController?.setEnumForView(delegate: self, view: view, enumType: FoodName.self, defaultEnum: selectedFoodName, onSelected: { (key, index) in + self.popOverViewController?.setEnumForView(delegate: self, view: view, enumType: FoodName.self, defaultEnum: selectedFoodName, separatorStyle: separatorStyle, onSelected: { (key, index) in self.selectedFoodName = key @@ -172,7 +174,7 @@ class RootViewController: UITableViewController, UIAdaptivePresentationControlle func openEnumMenu(view :UIView, allName: String) { self.popOverViewController = PopOverViewController.instantiate() - self.popOverViewController?.setEnumForView(delegate: self, view: view, enumType: FoodName.self, defaultEnum: selectedFoodName, allName: allName, onSelected: { (key, index) in + self.popOverViewController?.setEnumForView(delegate: self, view: view, enumType: FoodName.self, defaultEnum: selectedFoodName, allName: allName, separatorStyle: separatorStyle, onSelected: { (key, index) in print("key is \(String(describing: key)) , index is \(index) ") if index == 0 { diff --git a/Sample/Sample/SampleViewController.swift b/Sample/Sample/SampleViewController.swift index 0421d53..0c704ad 100644 --- a/Sample/Sample/SampleViewController.swift +++ b/Sample/Sample/SampleViewController.swift @@ -10,6 +10,8 @@ import PopOverMenu class SampleViewController: UIViewController, UIAdaptivePresentationControllerDelegate { + let separatorStyle: UITableViewCell.SeparatorStyle = .none + var popOverViewController: PopOverViewController? @IBOutlet weak var textLabel:UILabel? @@ -31,7 +33,7 @@ class SampleViewController: UIViewController, UIAdaptivePresentationControllerDe let titles = ["Menu1", "Menu2", "Menu3"] let descriptions = ["description1", "description2", "description3"] - self.popOverViewController?.setArrayForBarButtonItem(delegate: self, barButtonItem: sender, titles: titles, descriptions: descriptions, separatorStyle: .none) { (selectRow) in + self.popOverViewController?.setArrayForBarButtonItem(delegate: self, barButtonItem: sender, titles: titles, descriptions: descriptions, separatorStyle: separatorStyle) { (selectRow) in self.textLabel?.text = String(selectRow) } diff --git a/Sources/PopOverViewController+Array.swift b/Sources/PopOverViewController+Array.swift index 99902ec..952a653 100644 --- a/Sources/PopOverViewController+Array.swift +++ b/Sources/PopOverViewController+Array.swift @@ -4,7 +4,7 @@ extension PopOverViewController { - open func setArrayForView(delegate:UIAdaptivePresentationControllerDelegate, view: UIView, titles: [String]?, keys: [T]?, defaultKey: T?, allName: String, onSelected: @escaping (_ key:T?, _ index: Int) -> ()) { + open func setArrayForView(delegate:UIAdaptivePresentationControllerDelegate, view: UIView, titles: [String]?, keys: [T]?, defaultKey: T?, allName: String, separatorStyle: UITableViewCell.SeparatorStyle, onSelected: @escaping (_ key:T?, _ index: Int) -> ()) { guard let titles = titles else { return @@ -20,12 +20,12 @@ extension PopOverViewController { mutableTitles.insert(allName, at: 0) mutableKeys.insert(nil, at: 0) - setArrayForView(delegate: delegate, view: view, titles: mutableTitles, keys: mutableKeys, defaultKey: defaultKey) { (key, index) in + setArrayForView(delegate: delegate, view: view, titles: mutableTitles, keys: mutableKeys, defaultKey: defaultKey, separatorStyle: separatorStyle) { (key, index) in onSelected(key, index) } } - open func setArrayForView(delegate:UIAdaptivePresentationControllerDelegate, view: UIView, titles: [String]?, keys: [T?]?, defaultKey: T?, onSelected: @escaping (_ key: T?, _ index: Int) -> ()) { + open func setArrayForView(delegate:UIAdaptivePresentationControllerDelegate, view: UIView, titles: [String]?, keys: [T?]?, defaultKey: T?, separatorStyle: UITableViewCell.SeparatorStyle, onSelected: @escaping (_ key: T?, _ index: Int) -> ()) { guard let titles = titles else { return @@ -36,7 +36,7 @@ extension PopOverViewController { } self.set(showsVerticalScrollIndicator: true) - self.set(separatorStyle: .singleLine) + self.set(separatorStyle: separatorStyle) self.set(titles: titles) self.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.any @@ -50,7 +50,6 @@ extension PopOverViewController { } } - self.popoverPresentationController?.sourceView = view self.popoverPresentationController?.sourceRect = view.frame diff --git a/Sources/PopOverViewController+Enum.swift b/Sources/PopOverViewController+Enum.swift index 39cc003..c4fbe86 100644 --- a/Sources/PopOverViewController+Enum.swift +++ b/Sources/PopOverViewController+Enum.swift @@ -4,7 +4,7 @@ extension PopOverViewController { - open func setEnumForView(delegate: UIAdaptivePresentationControllerDelegate, view: UIView, enumType: T.Type, defaultEnum: T?, allName: String, onSelected: @escaping (_ key: T?, _ index: Int) -> ()) { + open func setEnumForView(delegate: UIAdaptivePresentationControllerDelegate, view: UIView, enumType: T.Type, defaultEnum: T?, allName: String, separatorStyle: UITableViewCell.SeparatorStyle, onSelected: @escaping (_ key: T?, _ index: Int) -> ()) { let baseTitles = enumType.allCases.map{$0.rawValue} @@ -19,7 +19,7 @@ extension PopOverViewController { } self.set(showsVerticalScrollIndicator: true) - self.set(separatorStyle: .singleLine) + self.set(separatorStyle: separatorStyle) self.set(titles: titles) self.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.any @@ -49,7 +49,7 @@ extension PopOverViewController { } } - open func setEnumForView(delegate: UIAdaptivePresentationControllerDelegate, view: UIView, enumType: T.Type, defaultEnum: T?, onSelected: @escaping (_ key: T?, _ index: Int) -> ()) { + open func setEnumForView(delegate: UIAdaptivePresentationControllerDelegate, view: UIView, enumType: T.Type, defaultEnum: T?, separatorStyle: UITableViewCell.SeparatorStyle, onSelected: @escaping (_ key: T?, _ index: Int) -> ()) { let baseTitles = enumType.allCases.map{$0.rawValue} @@ -62,7 +62,7 @@ extension PopOverViewController { } self.set(showsVerticalScrollIndicator: true) - self.set(separatorStyle: .singleLine) + self.set(separatorStyle: separatorStyle) self.set(titles: titles) self.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.any From 1067a321960eb0f71d767a4aab8b325d63472edf Mon Sep 17 00:00:00 2001 From: tichise Date: Tue, 17 Sep 2019 16:22:00 +0900 Subject: [PATCH 3/5] change sample --- Sample/Sample/RootViewController.swift | 2 +- Sample/Sample/SampleViewController.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sample/Sample/RootViewController.swift b/Sample/Sample/RootViewController.swift index 55e1518..58bc986 100644 --- a/Sample/Sample/RootViewController.swift +++ b/Sample/Sample/RootViewController.swift @@ -8,7 +8,7 @@ import PopOverMenu class RootViewController: UITableViewController, UIAdaptivePresentationControllerDelegate { - let separatorStyle: UITableViewCell.SeparatorStyle = .none + let separatorStyle: UITableViewCell.SeparatorStyle = .singleLine var popOverViewController: PopOverViewController? var section1 = ["Int Array", "String Array", "Int Array(All selectable)"] diff --git a/Sample/Sample/SampleViewController.swift b/Sample/Sample/SampleViewController.swift index 0c704ad..0098cf2 100644 --- a/Sample/Sample/SampleViewController.swift +++ b/Sample/Sample/SampleViewController.swift @@ -10,7 +10,7 @@ import PopOverMenu class SampleViewController: UIViewController, UIAdaptivePresentationControllerDelegate { - let separatorStyle: UITableViewCell.SeparatorStyle = .none + let separatorStyle: UITableViewCell.SeparatorStyle = .singleLine var popOverViewController: PopOverViewController? From 8a1f7483d75303f4424364074575daf1ddc2f603 Mon Sep 17 00:00:00 2001 From: tichise Date: Tue, 17 Sep 2019 16:22:12 +0900 Subject: [PATCH 4/5] erase the last separator --- Sources/PopOverViewController+TableView.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sources/PopOverViewController+TableView.swift b/Sources/PopOverViewController+TableView.swift index d88c995..88e353d 100644 --- a/Sources/PopOverViewController+TableView.swift +++ b/Sources/PopOverViewController+TableView.swift @@ -48,6 +48,11 @@ extension PopOverViewController { cell.accessoryType = selectRow == indexPath.row ? UITableViewCell.AccessoryType.checkmark : UITableViewCell.AccessoryType.none } + // Erase the last separator + if titles.count == indexPath.row + 1 { + cell.separatorInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: .greatestFiniteMagnitude) + } + return cell } From dcad9ebbbd1ddd4d55710dc121dada4e946d52ce Mon Sep 17 00:00:00 2001 From: tichise Date: Tue, 17 Sep 2019 16:22:23 +0900 Subject: [PATCH 5/5] add scheme --- Sample/Sample.xcodeproj/project.pbxproj | 4 +- .../xcshareddata/xcschemes/Sample.xcscheme | 78 +++++++++++++++++++ 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 Sample/Sample.xcodeproj/xcshareddata/xcschemes/Sample.xcscheme diff --git a/Sample/Sample.xcodeproj/project.pbxproj b/Sample/Sample.xcodeproj/project.pbxproj index 18fda1e..b8755cc 100644 --- a/Sample/Sample.xcodeproj/project.pbxproj +++ b/Sample/Sample.xcodeproj/project.pbxproj @@ -322,7 +322,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh", "${BUILT_PRODUCTS_DIR}/PopOverMenu/PopOverMenu.framework", ); name = "[CP] Embed Pods Frameworks"; @@ -331,7 +331,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; D8F8D2B702D51C2DA9AB421F /* [CP] Check Pods Manifest.lock */ = { diff --git a/Sample/Sample.xcodeproj/xcshareddata/xcschemes/Sample.xcscheme b/Sample/Sample.xcodeproj/xcshareddata/xcschemes/Sample.xcscheme new file mode 100644 index 0000000..e353969 --- /dev/null +++ b/Sample/Sample.xcodeproj/xcshareddata/xcschemes/Sample.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +