Skip to content

Commit 98a8b65

Browse files
authored
Merge pull request #8 from hryk224/feature/swift3_orientaion
Support orientation changed
2 parents d42d494 + 7f7e5fd commit 98a8b65

7 files changed

Lines changed: 119 additions & 64 deletions

File tree

Example/Example.xcodeproj/project.pbxproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
isa = PBXProject;
164164
attributes = {
165165
LastSwiftUpdateCheck = 0730;
166-
LastUpgradeCheck = 0730;
166+
LastUpgradeCheck = 0810;
167167
ORGANIZATIONNAME = "hiroyuki yoshida";
168168
TargetAttributes = {
169169
935BD6C41CE26EB600E5FDF7 = {
@@ -279,8 +279,10 @@
279279
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
280280
CLANG_WARN_EMPTY_BODY = YES;
281281
CLANG_WARN_ENUM_CONVERSION = YES;
282+
CLANG_WARN_INFINITE_RECURSION = YES;
282283
CLANG_WARN_INT_CONVERSION = YES;
283284
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
285+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
284286
CLANG_WARN_UNREACHABLE_CODE = YES;
285287
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
286288
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -324,8 +326,10 @@
324326
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
325327
CLANG_WARN_EMPTY_BODY = YES;
326328
CLANG_WARN_ENUM_CONVERSION = YES;
329+
CLANG_WARN_INFINITE_RECURSION = YES;
327330
CLANG_WARN_INT_CONVERSION = YES;
328331
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
332+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
329333
CLANG_WARN_UNREACHABLE_CODE = YES;
330334
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
331335
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -344,6 +348,7 @@
344348
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
345349
MTL_ENABLE_DEBUG_INFO = NO;
346350
SDKROOT = iphoneos;
351+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
347352
VALIDATE_PRODUCT = YES;
348353
};
349354
name = Release;

Example/Example/ImageCollectionViewCell.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ final class ImageCollectionViewCell: UICollectionViewCell {
1212
@IBOutlet weak var imageView: UIImageView!
1313
static let identifier = "ImageCollectionViewCell"
1414
static let nib = UINib(nibName: "ImageCollectionViewCell", bundle: nil)
15-
func configure(dequeueIndexPath: IndexPath) {
16-
let image = UIImage(named: String(dequeueIndexPath.item))
15+
func configure(_ indexPath: IndexPath) {
16+
let image = UIImage(named: String(indexPath.item))
1717
imageView.image = image
1818
setNeedsLayout()
1919
layoutIfNeeded()

Example/Example/Pattern1.storyboard

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="jtB-7l-rQl">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11535.1" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="jtB-7l-rQl">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
47
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11523"/>
69
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
710
</dependencies>
811
<scenes>
@@ -19,6 +22,7 @@
1922
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2023
<subviews>
2124
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" pagingEnabled="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="Lwf-cA-VEr" customClass="InfiniteCollectionView" customModule="InfiniteCollectionView">
25+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2226
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
2327
<collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="9XM-Ng-ou9">
2428
<size key="itemSize" width="600" height="600"/>
@@ -28,13 +32,15 @@
2832
</collectionViewFlowLayout>
2933
<cells/>
3034
</collectionView>
31-
<view alpha="0.5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="QjU-up-8Sl">
35+
<view userInteractionEnabled="NO" alpha="0.5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="QjU-up-8Sl">
36+
<rect key="frame" x="0.0" y="610" width="375" height="37"/>
3237
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3338
<constraints>
3439
<constraint firstAttribute="height" constant="37" id="Pl4-pn-Jed"/>
3540
</constraints>
3641
</view>
37-
<pageControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" numberOfPages="3" translatesAutoresizingMaskIntoConstraints="NO" id="RxI-o2-lRZ">
42+
<pageControl opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" numberOfPages="3" translatesAutoresizingMaskIntoConstraints="NO" id="RxI-o2-lRZ">
43+
<rect key="frame" x="0.0" y="610" width="375" height="37"/>
3844
<constraints>
3945
<constraint firstAttribute="height" constant="37" id="L4v-Uu-0PK"/>
4046
</constraints>

Example/Example/Pattern1ViewController.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class Pattern1ViewController: UIViewController {
2121
}
2222
@IBOutlet weak var layout: UICollectionViewFlowLayout! {
2323
didSet {
24-
layout.itemSize = CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
24+
layout.itemSize = UIScreen.main.bounds.size
2525
}
2626
}
2727
@IBOutlet weak var pageControl: UIPageControl! {
@@ -33,6 +33,14 @@ final class Pattern1ViewController: UIViewController {
3333
let storyboard = UIStoryboard(name: "Pattern1", bundle: nil)
3434
return storyboard.instantiateInitialViewController() as! Pattern1ViewController
3535
}
36+
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
37+
super.viewWillTransition(to: size, with: coordinator)
38+
layout.itemSize = size
39+
layout.invalidateLayout()
40+
collectionView.cellWidth = size.width
41+
collectionView.layoutIfNeeded()
42+
collectionView.setNeedsLayout()
43+
}
3644
}
3745

3846
// MARK: - InfiniteCollectionViewDataSource, InfiniteCollectionViewDelegate
@@ -42,7 +50,7 @@ extension Pattern1ViewController: InfiniteCollectionViewDataSource, InfiniteColl
4250
}
4351
func collectionView(_ collectionView: UICollectionView, dequeueForItemAt dequeueIndexPath: IndexPath, cellForItemAt usableIndexPath: IndexPath) -> UICollectionViewCell {
4452
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ImageCollectionViewCell.identifier, for: dequeueIndexPath) as! ImageCollectionViewCell
45-
cell.configure(dequeueIndexPath: usableIndexPath)
53+
cell.configure(usableIndexPath)
4654
return cell
4755
}
4856
func infiniteCollectionView(_ collectionView: UICollectionView, didSelectItemAt usableIndexPath: IndexPath) {

Example/Example/Pattern2.storyboard

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="OWH-Uo-QHx">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11535.1" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="OWH-Uo-QHx">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
47
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11523"/>
69
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
710
</dependencies>
811
<scenes>
@@ -19,16 +22,18 @@
1922
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2023
<subviews>
2124
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="blK-sK-Rl8">
25+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2226
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2327
<prototypes>
2428
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="InfiniteTableViewCell" rowHeight="161" id="1U1-fg-z8H" customClass="InfiniteTableViewCell" customModule="Example" customModuleProvider="target">
2529
<rect key="frame" x="0.0" y="28" width="375" height="161"/>
2630
<autoresizingMask key="autoresizingMask"/>
2731
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="1U1-fg-z8H" id="FjB-bh-baH">
28-
<frame key="frameInset" width="375" height="161"/>
32+
<rect key="frame" x="0.0" y="0.0" width="375" height="160.5"/>
2933
<autoresizingMask key="autoresizingMask"/>
3034
<subviews>
3135
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" pagingEnabled="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="g4o-O8-u5y" customClass="InfiniteCollectionView" customModule="InfiniteCollectionView">
36+
<rect key="frame" x="0.0" y="0.0" width="375" height="160.5"/>
3237
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
3338
<collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="JvE-3O-3Xs">
3439
<size key="itemSize" width="50" height="50"/>
@@ -38,13 +43,15 @@
3843
</collectionViewFlowLayout>
3944
<cells>
4045
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ImageCollectionViewCell" id="PWv-9R-TGh" customClass="ImageCollectionViewCell" customModule="Example" customModuleProvider="target">
41-
<rect key="frame" x="0.0" y="0.0" width="375" height="160"/>
46+
<rect key="frame" x="0.0" y="0.5" width="375" height="160"/>
4247
<autoresizingMask key="autoresizingMask"/>
4348
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
4449
<rect key="frame" x="0.0" y="0.0" width="375" height="160"/>
4550
<autoresizingMask key="autoresizingMask"/>
4651
<subviews>
47-
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="m9D-ne-YCP"/>
52+
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="m9D-ne-YCP">
53+
<rect key="frame" x="0.0" y="0.0" width="375" height="160"/>
54+
</imageView>
4855
</subviews>
4956
</view>
5057
<constraints>
@@ -60,13 +67,15 @@
6067
</collectionViewCell>
6168
</cells>
6269
</collectionView>
63-
<view alpha="0.5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cWs-n0-Daa">
70+
<view userInteractionEnabled="NO" alpha="0.5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cWs-n0-Daa">
71+
<rect key="frame" x="0.0" y="103.5" width="375" height="37"/>
6472
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
6573
<constraints>
6674
<constraint firstAttribute="height" constant="37" id="Jfa-Ja-OcD"/>
6775
</constraints>
6876
</view>
69-
<pageControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" numberOfPages="3" translatesAutoresizingMaskIntoConstraints="NO" id="TnJ-eK-8qD">
77+
<pageControl opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" numberOfPages="3" translatesAutoresizingMaskIntoConstraints="NO" id="TnJ-eK-8qD">
78+
<rect key="frame" x="0.0" y="103.5" width="375" height="37"/>
7079
<constraints>
7180
<constraint firstAttribute="height" constant="37" id="iLI-sf-nVD"/>
7281
</constraints>
@@ -97,10 +106,11 @@
97106
<rect key="frame" x="0.0" y="189" width="375" height="101"/>
98107
<autoresizingMask key="autoresizingMask"/>
99108
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Pbe-Q2-B3O" id="Vro-Kf-tWq">
100-
<frame key="frameInset" width="375" height="101"/>
109+
<rect key="frame" x="0.0" y="0.0" width="375" height="100.5"/>
101110
<autoresizingMask key="autoresizingMask"/>
102111
<subviews>
103112
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="ba3-za-Kdk" customClass="InfiniteCollectionView" customModule="InfiniteCollectionView">
113+
<rect key="frame" x="0.0" y="0.0" width="375" height="100.5"/>
104114
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
105115
<collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="10" minimumInteritemSpacing="10" id="9h8-PU-jeW">
106116
<size key="itemSize" width="100" height="100"/>
@@ -110,7 +120,7 @@
110120
</collectionViewFlowLayout>
111121
<cells>
112122
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ImageCollectionViewCell" id="HBK-Vd-0rJ" customClass="ImageCollectionViewCell" customModule="Example" customModuleProvider="target">
113-
<rect key="frame" x="0.0" y="0.0" width="100" height="100"/>
123+
<rect key="frame" x="0.0" y="0.5" width="100" height="100"/>
114124
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
115125
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
116126
<rect key="frame" x="0.0" y="0.0" width="100" height="100"/>

0 commit comments

Comments
 (0)