Skip to content

Commit 05c86b2

Browse files
committed
fix UIGestureRecognizerDelegate conflict bug
1 parent 08d1c0e commit 05c86b2

File tree

7 files changed

+10
-29
lines changed

7 files changed

+10
-29
lines changed

.swiftlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ disabled_rules: # rule identifiers to exclude from running
33
- nesting
44
- variable_name_min_length
55
- cyclomatic_complexity
6+
- class_delegate_protocol
67
included: # paths to include during linting. `--path` is ignored if present. takes precendence over `excluded`.
78
excluded: # paths to ignore during linting. overridden by `included`.
89
- Carthage

Example/EmptyDataDemoCollectionViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class EmptyDataDemoCollectionViewController: UICollectionViewController {
7373
self.dataCount -= 1
7474
collectionView.performBatchUpdates({
7575
self.collectionView?.deleteItems(at: [indexPath])
76-
}) { (completed) in
76+
}) { (_) in
7777

7878
}
7979
}

Example/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.4</string>
18+
<string>2.5</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>15</string>
22+
<string>16</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UILaunchStoryboardName</key>

TBEmptyDataSet.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "TBEmptyDataSet"
4-
s.version = "2.4"
4+
s.version = "2.5"
55
s.summary = "An extension of UITableView/UICollectionView's super class, it will display a placeholder when the data is empty."
66

77
s.homepage = "https://github.com/teambition/TBEmptyDataSet"

TBEmptyDataSet/EmptyDataView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ internal class EmptyDataView: UIView {
125125
let centerY = NSLayoutConstraint(item: contentView, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1, constant: verticalOffset)
126126
addConstraint(centerX)
127127
addConstraint(centerY)
128-
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[\(ViewStrings.contentView)]|", options: [], metrics: nil, views: [ViewStrings.contentView : contentView]))
128+
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[\(ViewStrings.contentView)]|", options: [], metrics: nil, views: [ViewStrings.contentView: contentView]))
129129

130130
if let customView = customView {
131131
let translatesFrameIntoConstraints = customView.translatesAutoresizingMaskIntoConstraints
@@ -168,7 +168,7 @@ internal class EmptyDataView: UIView {
168168
let viewString = ViewStrings.titleLabel
169169
viewStrings.append(viewString)
170170
views[viewString] = titleLabel
171-
contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-[\(ViewStrings.titleLabel)(>=0)]-|", options: [], metrics: nil, views: [ViewStrings.titleLabel : titleLabel]))
171+
contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-[\(ViewStrings.titleLabel)(>=0)]-|", options: [], metrics: nil, views: [ViewStrings.titleLabel: titleLabel]))
172172
} else {
173173
titleLabel.removeFromSuperview()
174174
}
@@ -180,7 +180,7 @@ internal class EmptyDataView: UIView {
180180
let viewString = ViewStrings.descriptionLabel
181181
viewStrings.append(viewString)
182182
views[viewString] = descriptionLabel
183-
contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-[\(ViewStrings.descriptionLabel)(>=0)]-|", options: [], metrics: nil, views: [ViewStrings.descriptionLabel : descriptionLabel]))
183+
contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-[\(ViewStrings.descriptionLabel)(>=0)]-|", options: [], metrics: nil, views: [ViewStrings.descriptionLabel: descriptionLabel]))
184184
} else {
185185
descriptionLabel.removeFromSuperview()
186186
}

TBEmptyDataSet/Supporting Files/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.4</string>
18+
<string>2.5</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

TBEmptyDataSet/TBEmptyDataSet.swift

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import UIKit
1010

11-
extension UIScrollView: UIGestureRecognizerDelegate {
11+
extension UIScrollView {
1212
// MARK: - Properties
1313
public var emptyDataSetDataSource: TBEmptyDataSetDataSource? {
1414
get {
@@ -125,7 +125,6 @@ extension UIScrollView: UIGestureRecognizerDelegate {
125125
emptyDataView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
126126
emptyDataView.isHidden = true
127127
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(didTapEmptyDataView(_:)))
128-
tapGesture.delegate = self
129128
emptyDataView.addGestureRecognizer(tapGesture)
130129
emptyDataView.tapGesture = tapGesture
131130
return emptyDataView
@@ -174,21 +173,6 @@ extension UIScrollView: UIGestureRecognizerDelegate {
174173
emptyDataSetDelegate?.emptyDataSetDidDisappear(in: self)
175174
}
176175

177-
// MARK: - UIGestureRecognizer delegate
178-
override open func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
179-
if gestureRecognizer.view is EmptyDataView {
180-
return emptyDataSetTapEnabled()
181-
}
182-
return super.gestureRecognizerShouldBegin(gestureRecognizer)
183-
}
184-
185-
open func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
186-
if let emptyDataView = emptyDataView, gestureRecognizer == emptyDataView.tapGesture || otherGestureRecognizer == emptyDataView.tapGesture {
187-
return true
188-
}
189-
return false
190-
}
191-
192176
// MARK: - Display
193177
// swiftlint:disable function_body_length
194178
fileprivate func reloadEmptyDataSet() {
@@ -273,7 +257,6 @@ extension UIScrollView: UIGestureRecognizerDelegate {
273257
let swizzledSelector = Selectors.tableViewSwizzledReloadData
274258

275259
tb_swizzleMethod(for: UITableView.self, originalSelector: originalSelector, swizzledSelector: swizzledSelector)
276-
print("tb_swizzleTableViewReloadData")
277260
}()
278261

279262
// swiftlint:disable variable_name
@@ -282,7 +265,6 @@ extension UIScrollView: UIGestureRecognizerDelegate {
282265
let swizzledSelector = Selectors.tableViewSwizzledEndUpdates
283266

284267
tb_swizzleMethod(for: UITableView.self, originalSelector: originalSelector, swizzledSelector: swizzledSelector)
285-
print("tb_swizzleTableViewEndUpdates")
286268
}()
287269

288270
// swiftlint:disable variable_name
@@ -291,7 +273,6 @@ extension UIScrollView: UIGestureRecognizerDelegate {
291273
let swizzledSelector = Selectors.collectionViewSwizzledReloadData
292274

293275
tb_swizzleMethod(for: UICollectionView.self, originalSelector: originalSelector, swizzledSelector: swizzledSelector)
294-
print("tb_swizzleCollectionViewReloadData")
295276
}()
296277

297278
// swiftlint:disable variable_name
@@ -300,7 +281,6 @@ extension UIScrollView: UIGestureRecognizerDelegate {
300281
let swizzledSelector = Selectors.collectionViewSwizzledPerformBatchUpdates
301282

302283
tb_swizzleMethod(for: UICollectionView.self, originalSelector: originalSelector, swizzledSelector: swizzledSelector)
303-
print("tb_swizzleCollectionViewPerformBatchUpdates")
304284
}()
305285

306286
func tb_tableViewSwizzledReloadData() {

0 commit comments

Comments
 (0)