Skip to content

Commit

Permalink
make top view always can scroll and wrong content size when rotation …
Browse files Browse the repository at this point in the history
…the device
  • Loading branch information
huiping192 committed Sep 12, 2015
1 parent 5263348 commit 2bd43f0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
25 changes: 12 additions & 13 deletions LolTube/Module/Top/TopViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ class TopViewController: UIViewController {
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)

self.videosCollectionView.collectionViewLayout.invalidateLayout()
coordinator.animateAlongsideTransition({
[unowned self]_ in
self.videosCollectionView.reloadData()
self.videosCollectionView.reloadData()

coordinator.animateAlongsideTransition(nil, completion: {
_ in
self.layoutCollectionViewSize()

}, completion:nil)

})


}

Expand Down Expand Up @@ -107,24 +108,23 @@ class TopViewController: UIViewController {

let successBlock:(() -> Void) = {
[weak self] in

self?.configureTopView()
self?.videosCollectionView.reloadData()
self?.layoutCollectionViewSize()

self?.stopLoadingAnimation()

Async.main{
UIView.animateWithDuration(0.1) {
[weak self] in
self?.mainScrollView.alpha = 1.0
}
UIView.animateWithDuration(0.1) {
self?.mainScrollView.alpha = 1.0
}
}

let failureBlock:((NSError) -> Void) = {
[weak self]error in
self?.showError(error)
self?.stopLoadingAnimation()
self?.mainScrollView.alpha = 1.0
}

viewModel.update(successBlock, failure: failureBlock)
Expand Down Expand Up @@ -161,7 +161,6 @@ class TopViewController: UIViewController {
// MARK: view cconfiguration
private func layoutCollectionViewSize() {
Async.main{
[unowned self] in
self.collectionHeightConstraint.constant = self.videosCollectionView.contentSize.height
self.videosCollectionView.layoutIfNeeded()
}
Expand Down Expand Up @@ -361,7 +360,7 @@ extension TopViewController: UICollectionViewDelegateFlowLayout {
}

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize{
return section == collectionView.numberOfSections() - 1 ? CGSizeZero : CGSize(width: collectionView.frame.width, height: 12)
return section == collectionView.numberOfSections() - 1 ? CGSizeZero : CGSize(width: collectionView.frame.width, height: 8)
}

}
Expand Down
12 changes: 6 additions & 6 deletions LolTube/StoryBoard/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8187.4" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="zba-lz-CV3">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="zba-lz-CV3">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8151.3"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
Expand Down Expand Up @@ -898,7 +898,7 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="q87-ZK-g0W">
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="q87-ZK-g0W">
<rect key="frame" x="0.0" y="64" width="600" height="487"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cWl-kr-h8k" userLabel="top banner View">
Expand Down Expand Up @@ -951,7 +951,7 @@
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="0.0" minimumInteritemSpacing="8" id="Led-wQ-uJf">
<size key="itemSize" width="150" height="130"/>
<size key="headerReferenceSize" width="320" height="44"/>
<size key="footerReferenceSize" width="0.0" height="12"/>
<size key="footerReferenceSize" width="0.0" height="8"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells>
Expand Down Expand Up @@ -1114,7 +1114,7 @@
</connections>
</collectionReusableView>
<collectionReusableView key="sectionFooterView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="footerView" id="gbb-PG-8nK" customClass="TopVideoCollectionFooterView" customModule="LolTube" customModuleProvider="target">
<rect key="frame" x="0.0" y="174" width="600" height="12"/>
<rect key="frame" x="0.0" y="174" width="600" height="8"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="aDq-kO-wD4" userLabel="Top Space View">
Expand All @@ -1126,7 +1126,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vHb-x9-lRh" userLabel="Bot Space View">
<rect key="frame" x="0.0" y="11" width="600" height="1"/>
<rect key="frame" x="0.0" y="7" width="600" height="1"/>
<animations/>
<color key="backgroundColor" red="0.87493738619999994" green="0.87382725449999998" blue="0.89321848999999998" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
Expand Down

0 comments on commit 2bd43f0

Please sign in to comment.