Skip to content

Add layout() method to support Xcode playgrounds. - #103

Merged
lucdion merged 5 commits into
masterfrom
layout_method
Nov 22, 2017
Merged

lucdion merged 5 commits into
masterfrom
layout_method

Conversation

@lucdion

@lucdion lucdion commented Nov 21, 2017 •

Copy link
Copy Markdown
Member

Changes:

Add layout() method

PinLayout layouts views immediately after the line containing .pin has been fully executed, thanks to ARC (Automatic Reference Counting) this works perfectly on iOS/tvOS/macOS simulators and devices. But in Xcode Playgrounds, ARC doesn't work as expected, object references are kept much longer. This is a well-documented issue. The impact of this problem is that PinLayout doesn't layout views at the time and in the order required. To handle this situation in playgrounds it is possible to call the layout() method to complete the layout.

  • layout()
    The method will execute PinLayout commands immediately. This method is required only if your source codes should also work in Xcode Playgrounds. Outside of playgrounds, PinLayout executes this method implicitly, it is not necessary to call it.
Usage Examples:
    view.pin.top(20).bottom(20).width(100).layout()
    view2.pin.below(of: view).left().right().layout()

TIP: If your codes need to work in Xcode playgrounds, you may set to true the property Pin.warnMissingLayoutCalls, this way any missing call to layout() will generate a warning in the Xcode console.

@codecov-io

codecov-io commented Nov 21, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #103 into master will increase coverage by 0.35%.
The diff coverage is 93.13%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #103      +/-   ##
==========================================
+ Coverage   89.93%   90.28%   +0.35%     
==========================================
  Files          31       33       +2     
  Lines        6069     6175     +106     
==========================================
+ Hits         5458     5575     +117     
+ Misses        611      600      -11
Impacted Files Coverage Δ
Sources/Impl/UnitTests.swift 100% <ø> (ø) ⬆️
Sources/PinLayout.swift 100% <ø> (ø) ⬆️
Tests/RelativePositionMultipleViewsSpec.swift 100% <100%> (ø) ⬆️
Tests/MinMaxWidthHeightSpec.swift 100% <100%> (ø) ⬆️
Sources/Pin.swift 100% <100%> (ø)
Tests/AspectRatioTests.swift 100% <100%> (ø) ⬆️
Tests/WarningSpec.swift 100% <100%> (ø) ⬆️
Tests/ObjectiveCSpec.m 100% <100%> (ø)
Tests/PinEdgesSpec.swift 100% <100%> (ø) ⬆️
Tests/RTLSpec.swift 100% <100%> (ø) ⬆️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b1677a...a5a662b. Read the comment docs.

@lucdion
lucdion merged commit af4905a into master Nov 22, 2017
@lucdion
lucdion deleted the layout_method branch November 22, 2017 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants