Skip to content

Commit 43f76b4

Browse files
author
jiaxiang.tan
committed
Fixed cell offset bug: when XIB loaded JXBanner with Pagecount equal to 1
JXBanner/Classes/Banner/Banner/JXBannerLayout.swift
1 parent f08b0e6 commit 43f76b4

File tree

5 files changed

+31
-23
lines changed

5 files changed

+31
-23
lines changed

Example/JXBanner.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@
632632
PRODUCT_NAME = "$(TARGET_NAME)";
633633
PROVISIONING_PROFILE_SPECIFIER = "";
634634
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
635-
SWIFT_VERSION = 4.0;
635+
SWIFT_VERSION = 5.0;
636636
};
637637
name = Debug;
638638
};
@@ -652,7 +652,7 @@
652652
PRODUCT_NAME = "$(TARGET_NAME)";
653653
PROVISIONING_PROFILE_SPECIFIER = "";
654654
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
655-
SWIFT_VERSION = 4.0;
655+
SWIFT_VERSION = 5.0;
656656
};
657657
name = Release;
658658
};

Example/JXBanner/Info.plist

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>NSAppTransportSecurity</key>
6-
<dict>
7-
<key>NSAllowsArbitraryLoads</key>
8-
<true/>
9-
</dict>
105
<key>CFBundleDevelopmentRegion</key>
116
<string>en</string>
127
<key>CFBundleDisplayName</key>
@@ -29,6 +24,11 @@
2924
<string>1</string>
3025
<key>LSRequiresIPhoneOS</key>
3126
<true/>
27+
<key>NSAppTransportSecurity</key>
28+
<dict>
29+
<key>NSAllowsArbitraryLoads</key>
30+
<true/>
31+
</dict>
3232
<key>UILaunchStoryboardName</key>
3333
<string>LaunchScreen</string>
3434
<key>UIMainStoryboardFile</key>
@@ -41,6 +41,7 @@
4141
<array>
4242
<string>UIInterfaceOrientationPortrait</string>
4343
<string>UIInterfaceOrientationLandscapeLeft</string>
44+
<string>UIInterfaceOrientationLandscapeRight</string>
4445
</array>
4546
</dict>
4647
</plist>

Example/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 10 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

JXBanner.podspec

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

99
Pod::Spec.new do |s|
1010
s.name = 'JXBanner'
11-
s.version = '0.3.1'
11+
s.version = '0.3.2'
1212
s.summary = 'A multifunctional framework for banner unlimited rollover diagrams'
1313

1414
# This description is used to generate tags and improve search results.

JXBanner/Classes/Banner/Banner/JXBannerLayout.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,28 @@ class JXBannerLayout: UICollectionViewFlowLayout {
2121
var params: JXBannerLayoutParams? {
2222
didSet {
2323
if let params = params {
24+
shouldInvalidateLayout = true
2425
itemSize = params.itemSize ?? collectionView?.bounds.size ?? CGSize(width: 2, height: 2)
2526
minimumLineSpacing = params.itemSpacing
2627
minimumInteritemSpacing = params.itemSpacing
2728
}
2829
}
2930
}
30-
31+
32+
/// Fixed cell offset bug: when XIB loaded JXBanner with Pagecount equal to 1
33+
var shouldInvalidateLayout = true
34+
3135
var isPagingEnabled: Bool = true
3236

3337
override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) ->
3438
Bool {
35-
if let _ = params?.layoutType { return true }
36-
return super.shouldInvalidateLayout(forBoundsChange: newBounds)
39+
40+
if shouldInvalidateLayout || params?.layoutType != nil {
41+
shouldInvalidateLayout = false
42+
return true
43+
}
44+
45+
return super.shouldInvalidateLayout(forBoundsChange: newBounds)
3746
}
3847

3948
override func prepare() {

0 commit comments

Comments
 (0)