Skip to content

Commit 43d69b5

Browse files
committed
Merge branch 'CollectionViewContentViewKey'
2 parents 4ddab58 + 32caa68 commit 43d69b5

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

Sources/Models/Views/ScrollViews/CollectionView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,11 @@ public struct CollectionViewCell: IBDecodable, ViewProtocol, IBIdentifiable, IBR
288288
case .isAmbiguous: return "ambiguous"
289289
case .isHidden: return "hidden"
290290
case ._subviews: return "subview"
291-
case .contentView: return "view"
291+
case .contentView:
292+
if xml.childrenElements.contains(where: {$0.elementName == "collectionViewCellContentView"}) {
293+
return "collectionViewCellContentView"
294+
}
295+
return "view"
292296
default: return key.stringValue
293297
}
294298
}()

Tests/IBDecodableTests/Tests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,24 @@ class Tests: XCTestCase {
392392
}
393393
}
394394

395+
func testCollectionViewCellContentView_WithNewCollectionViewCellContentView() {
396+
let url = self.url(forResource: "CollectionViewCellWithContentView", withExtension: "xib")
397+
do {
398+
let file = try XibFile(url: url)
399+
let rootView = file.document.views?.first?.view
400+
XCTAssertNotNil(rootView, "There should be a root view")
401+
XCTAssertEqual(rootView?.elementClass, "UICollectionViewCell")
402+
403+
guard let cell = rootView as? CollectionViewCell else {
404+
XCTFail("The root view should be a collection view cell")
405+
return
406+
}
407+
XCTAssertEqual(cell.contentView.key, "contentView")
408+
} catch {
409+
XCTFail("\(error) \(url)")
410+
}
411+
}
412+
395413
func testCollectionReusableView() {
396414
let url = self.url(forResource: "CollectionReusableView", withExtension: "xib")
397415
do {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
4+
<dependencies>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
6+
<capability name="collection view cell content view" minToolsVersion="11.0"/>
7+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
8+
</dependencies>
9+
<objects>
10+
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
11+
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
12+
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="Mb7-D0-dPa">
13+
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
14+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
15+
<collectionViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="YwU-He-qVe">
16+
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
17+
<autoresizingMask key="autoresizingMask"/>
18+
</collectionViewCellContentView>
19+
<point key="canvasLocation" x="-274" y="-132"/>
20+
</collectionViewCell>
21+
</objects>
22+
</document>

0 commit comments

Comments
 (0)