GithubHelp home page GithubHelp logo

fdstackview's Introduction

FDStackView

Use UIStackView as if it supports iOS6. forkingdog

Problem

UIStackView is a very handy tool to build flow layout, but it's available only when iOS9+, we've found some great compatible replacements like OAStackView, but we want more:

  • Perfect downward compatible, no infectivity, use UIStackView directly as if it's shipped from iOS6.
  • Interface builder support, live preview.
  • Keep layout constraints as closely as UIStackView constructs.

Usage

Podfile

platform :ios, '7.0'
pod "FDStackView", "1.0"

Import nothing, learn nothing, it just works.

  • It will automatically replace the symbol for UIStackView into FDStackView at runtime before iOS9.
// Works in iOS6+, use it directly.
UIStackView *stackView = [[UIStackView alloc] init];
stackView.axis = UILayoutConstraintAxisHorizontal;
stackView.distribution = UIStackViewDistributionFill;
stackView.alignment = UIStackViewAlignmentTop;
[stackView addArrangedSubview:[[UILabel alloc] init]];
[self.view addSubview:stackView];
  • Interface Builder Support

Set Builds for option to iOS 9.0 and later to eliminate the version error in Xcode:

How to use in IB

Now, use UIStackView as you like and its reactive options and live preview:

UIStackView preview in IB

Requirements

  • Xcode 7+ (For interface builder supports and the latest Objective-C Syntax)
  • Base SDK iOS 9.0+ (To link UIStackView symbol in UIKit)

Versions

  • 1.0.1 is the lastest version. We released it after we have used it in our official application. And it was successfully passed through the App Store's review. So you have no concern to use it.

License

The MIT License (MIT)

Copyright (c) 2015-2016 forkingdog ( https://github.com/forkingdog )

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

fdstackview's People

Contributors

sdaheng avatar sinojerk avatar sunnyxx avatar wtlucky avatar zxm9988 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fdstackview's Issues

Swift中Storyboard使用,iOS7.1下Crash

调试了一下午,发现是UINibDecodeXXXX类在解析Segue时crash的,同一个Storyboard把UIStackView去掉,Builds for改成默认的iOS7,可运行。包含UIStackView,但不要Segue,可运行。

Use with swift

Hi,

I'd like to use this lib with swift 3. I've added the files directly to my project (I need to use dynamic frameworks so no cocoapod with this one). Then I've added a bridging header so it seems that all is good. My issue is the availability, Xcode require me to use availability to check if sdk is > 9.

I've added the customs flags to disable compatibility check as in #2

The issue is I use compatibility for other things like notifications so I can't really disable it. Is there a way to disable it for only a particular place in the code ?

释放的时候kvo crash了。。。。iOS8.1模拟器

2015-10-09 18:14:45.803 Qingwen[74545:2004789] *** Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <UIStackView 0x7fb183c8d350> for the key path "hidden" from <UIStackView 0x7fb183c99490> because it is not registered as an observer.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001074b7f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000107124bb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001074b7e6d +[NSException raise:format:] + 205
3 Foundation 0x0000000104375609 -[NSObject(NSKeyValueObserverRegistration) _removeObserver:forProperty:] + 608
4 Foundation 0x000000010437530c -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:] + 90
5 Qingwen 0x0000000102ec018b -[FDStackView removeHiddenObserverForView:] + 91
6 Qingwen 0x0000000102ebf8e5 -[FDStackView removeArrangedSubview:] + 421
7 Qingwen 0x0000000102ebf6fe -[FDStackView willRemoveSubview:] + 62
8 UIKit 0x000000010526649c __UIViewWillBeRemovedFromSuperview + 142
9 UIKit 0x00000001052661c9 -[UIView(Hierarchy) removeFromSuperview] + 91
10 UIKit 0x0000000105259e39 -[UIView dealloc] + 404
11 Qingwen 0x0000000102ec04af -[FDStackView dealloc] + 223
12 CoreFoundation 0x000000010738f78b CFRelease + 603
13 CoreFoundation 0x00000001073a30bd -[__NSArrayM dealloc] + 157
14 libobjc.A.dylib 0x000000010713928e _ZN11objc_object17sidetable_releaseEb + 236
15 libobjc.A.dylib 0x00000001071398cd _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 591
16 CoreFoundation 0x00000001073aeda6 _CFAutoreleasePoolPop + 22
17 CoreFoundation 0x00000001073e2ef3 __CFRunLoopRun + 2051
18 CoreFoundation 0x00000001073e2486 CFRunLoopRunSpecific + 470
19 GraphicsServices 0x000000010a31c9f0 GSEventRunModal + 161
20 UIKit 0x00000001051fb420 UIApplicationMain + 1282
21 Qingwen 0x0000000102ea4e0f main + 111
22 libdyld.dylib 0x00000001081ce145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Not work if integrated using pod as dynamic library

Currently I try to update pod to use dynamic library as some of pods need the project using dynamic library if update them to latest version.
After update, I found the FDStackView not working. I have to use FDStackView in old way, copy to project.
Anyone has solution? It sucks to copy file to project.

ios7 crash

device: iPhone 4 iOS 7.1.2
step: add->remove->add

Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to install constraint on view. Does the constraint reference something from outside the subtree of the view? That's illegal. constraint:<NSLayoutConstraint:0x16df7cb0 'FDSV-spacing' H:[UILabel:0x16df05c0]-(0)-[UILabel:0x16d52d40]> view:<UIStackView: 0x16ded770; frame = (0 0; 320 100); autoresize = RM+BM; layer = <FDTransformLayer: 0x16ded9b0>>'

在iOS10上removeAllSubviews后,再调用addArrangedSubview Crash

在iOS10上removeAllSubviews后,再调用addArrangedSubview Crash,什么原因?

报错:
Assertion failure in -[FDStackView _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3600.7.47/NSLayoutConstraint_UIKitAdditions.m:649
invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.

Return nil if it's compiled as a dynamic framework

I use CocoaPods to manage third-party libraries.

There are some reasons causes I had to add use_frameworks! to the Podfile, so all of the libraries are compiled as a dynamic framework.

But I found that if FDStackView is compiled into a dynamic framework, it will return nil when it's initialized.

Is there any workaround? I don't want to add the code to my project manually.

FYI:
Objective-C-based project.
iOS 8.

UIStackView can't be used when the deployment target is lower than 9.0 and Cocoapods version is 1.1.0.rc3

When I update Cocoapods to 1.1.0.rc3
It seems the verifying is more strict in CocoaPods

Showing All Messages
ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target 7.0 --output-format human-readable-text --compile /Users/jenkins/Library/Developer/Xcode/DerivedData/EMStock-ejggipzgbvudbrelswbgumssqjfg/Build/Products/Debug-iphonesimulator/EMStock.app/EMIndDetailCell.nib /Users/jenkins/Desktop/[email protected]/Pods/EMMarket/EMMarket/StockDetail/Classes/view/EMIndDetailCell.xib --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk --target-device iphone

Layout margins

Hi,

When running on OS8.3 the IB placed layout margins are ignored, is this padding feature supported?
layoutMarginsRelativeArrangement is being set to YES

cheers

Crash on iOS 7.1

在Storyboard的一个Controller里添加了FDStackView,用代码dismiss该controller时崩溃在FDStackViewDistributionLayoutArrangement.m第226行:[self.canvas removeConstraints:self.relatedDimensionConstraints.fd_allObjects];
控制台输出:
Objective: {objective 0x178839a40: <999:-18.4039, 998:-342.146, 997:25.7032, 996:-0.509864, 750:826, 251:789, 25:1248> + <750:1, 251:1>_0x1708ad740.negError{id: 1554} + <750:1, 251:1>_0x1708ad7a0.negError{id: 1558} + <750:1, 251:1>_0x1708ad800.negError{id: 1560} + <750:1, 251:1>_0x1708ad8c0.posErrorMarker{id: 1561} + <750:1, 251:1>_0x1708ad920.posErrorMarker{id: 1563} + 750:1_0x1708ad980.negError{id: 1574} + <750:-6.44498e-07, 251:1>_0x1708ad980.posErrorMarker{id: 1573} + <750:1, 25:-2>_0x1708ad9e0.negError{id: 1576} + <251:1, 25:2>_0x1708ad9e0.posErrorMarker{id: 1575} + <750:1, 251:1>_0x1708adb60.negError{id: 1632} + <750:1, 251:1>_0x1708adbc0.negError{id: 1634} + <750:1, 251:1>_0x1708adc20.negError{id: 1636} + <750:1, 251:1>_0x1708adc80.negError{id: 1638} + <750:-2, 251:4>_0x171280320.marker{id: 1262} + <750:-2, 251:4>_0x171280780.marker{id: 1274} + 251:1_0x17128c990.marker{id: 1470} + 51:2_0x17128d3e0:FDSV-spanning-fit.negError{id: 1387} + 999.5:2_0x17128d430:FDSV-spanning-boundary.posErrorMarker{id: 1389} + 999.5:1_0x17128d480:FDSV-spanning-boundary.error{id: 1394} + 999.5:1_0x17128d4d0:FDSV-spanning-boundary.negError{id: 1397} + 999.5:1_0x17128d4d0:FDSV-spanning-boundary.posErrorMarker{id: 1396} + 999.5:1_0x17128d520:FDSV-spanning-boundary.error{id: 1400} + 999.5:2_0x17128d570:FDSV-spanning-boundary.negError{id: 1402} + 999.5:1_0x17128d5c0:FDSV-spanning-boundary.error{id: 1405} + 251:1_0x17128d610.marker{id: 1316} + 999.5:2_0x17128d660:FDSV-spanning-boundary.posErrorMarker{id: 1406} + 251:1_0x17128d930.marker{id: 1318} + 750:-1_0x17128db60.marker{id: 1320} + 251:-1_0x17128dc50.marker{id: 1428} + 251:-1_0x17128dcf0.marker{id: 1434} + 251:-1_0x17128dd90.marker{id: 1439} + 251:-1_0x17128dde0.marker{id: 1441} + 750:0_0x17128de80.marker{id: 1445} + 750:0_0x17128ded0.marker{id: 1447} + 750:1_0x17128df20.marker{id: 1450} + 750:1_0x17128dfc0.marker{id: 1455} + 251:1_0x17128e1f0.marker{id: 1474} + 251:1_0x17128e240.marker{id: 1476} + <750:1, 251:-2>_0x17128e2e0.marker{id: 1478} + <750:1, 251:-2>_0x17128e330.marker{id: 1481} + 750:0_0x1712940a0:FDSV-fill-proportionally.negError{id: 1606} + 750:0_0x171294280:FDSV-fill-proportionally.negError{id: 1610} + 25:2_0x1712946e0:FDSV-ambiguity-suppression.negError{id: 1620} + 25:2_0x1712948c0:FDSV-ambiguity-suppression.negError{id: 1623} + 999.5:1_0x1712949b0:FDSV-alignment.marker{id: 1624} + 25:2_0x171294aa0:FDSV-ambiguity-suppression.negError{id: 1626} + 999.5:-1_0x171294b90:FDSV-alignment.marker{id: 1627} + 25:2_0x171294c80:FDSV-ambiguity-suppression.negError{id: 1629} + 999.5:1_0x171294d70:FDSV-alignment.marker{id: 1630} + <750:-1, 251:2>_0x178a86f90.marker{id: 112} + 999:2_0x178aab760.negError{id: 1507} + 999:2_0x178aab7c0.negError{id: 1510} + <750:1, 251:1>_0x178aac6c0.negError{id: 1556} + 750:1_0x178aac720.negError{id: 1566} + 250:1_0x178aac720.posErrorMarker{id: 1565} + 750:1_0x178aac780.negError{id: 1568} + 250:1_0x178aac780.posErrorMarker{id: 1567} + 750:1_0x178aac8a0.negError{id: 1578} + 250:1_0x178aac8a0.posErrorMarker{id: 1577} + 750:1_0x178aac900.negError{id: 1580} + 250:1_0x178aac900.posErrorMarker{id: 1579} + 750:1_0x178aac960.negError{id: 1582} + 251:1_0x178aac960.posErrorMarker{id: 1581} + <750:1, 25:-2>_0x178aac9c0.negError{id: 1584} + <251:1, 25:2>_0x178aac9c0.posErrorMarker{id: 1583} + 750:1_0x178aaca20.negError{id: 1586} + <750:0, 251:1>_0x178aaca20.posErrorMarker{id: 1585} + <750:1, 25:-2>_0x178aaca80.negError{id: 1588} + <251:1, 25:2>_0x178aaca80.posErrorMarker{id: 1587} + 750:1_0x178aacae0.negError{id: 1590} + 250:1_0x178aacae0.posErrorMarker{id: 1589} + 750:1_0x178aacb40.negError{id: 1592} + 250:1_0x178aacb40.posErrorMarker{id: 1591} + 750:1_0x178aacba0.negError{id: 1594} + <750:0, 251:1>0x178aacba0.posErrorMarker{id: 1593} + <750:1, 25:-2>0x178aacc00.negError{id: 1596} + <251:1, 25:2>0x178aacc00.posErrorMarker{id: 1595} + <750:-2, 251:4>0x179283020.marker{id: 1305} + 251:1_0x179289650.marker{id: 1473} + 999.5:1_0x179289dd0:FDSV-spanning-boundary.error{id: 1410} + 999.5:2_0x179289e20:FDSV-spanning-boundary.negError{id: 1412} + 999.5:1_0x179289e70:FDSV-spanning-boundary.error{id: 1415} + 25:2_0x179289fb0:FDSV-ambiguity-suppression.negError{id: 1337} + 25:2_0x17928a050:FDSV-ambiguity-suppression.negError{id: 1340} + 25:2_0x17928a0f0:FDSV-ambiguity-suppression.negError{id: 1350} + 25:2_0x17928a190:FDSV-ambiguity-suppression.negError{id: 1353} + <750:-1, 251:2>0x17928a5a0.marker{id: 1519} + 750:0_0x179290680:FDSV-canvas-connection.marker{id: 1597} + 750:0_0x1792906d0.marker{id: 1598} + <750:-2, 251:4>0x1792920c0.marker{id: 1688} + 750:0<orphaned without delegate (bug!):0x178a27620>{id: 148} + 750:0<orphaned without delegate (bug!):0x178a27ce0>{id: 179} + 750:0<orphaned without delegate (bug!):0x178a27e40>{id: 186} + 750:6.37025e-07<orphaned without delegate (bug!):0x178a27e60>{id: 187} + 750:0<orphaned without delegate (bug!):0x178a2aca0>{id: 420} + 750:0<orphaned without delegate (bug!):0x178a2ade0>{id: 424} + 51:1_FDLayoutSpacer:0x178588470.Width{id: 1388} + 750:0_UIImageView:0x1703eb600.Width{id: 1334} + 750:0_UIImageView:0x1703eba00.minX{id: 1370} + 750:0_UIImageView:0x1783ecc00.minX{id: 1372} + 750:0_UIImageView:0x1783ecf00.minX{id: 1375} + 999:1__UILayoutGuide:0x178588540.Width{id: 1508} + 999:1*_UILayoutGuide:0x178588610.Width{id: 1511}}

iOS 8 crash

我在一个stackView中嵌套加了一个stackView, 嵌套的stackView动态添加imageView 在iOS8 crash, iOS9 正常。

The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x7f838fe60440 UIStackView:0x7f838fd331d0.leading == UIImageView:0x7f838fc30c10.leading>
    When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView _viewHierarchyUnpreparedForConstraint:] to debug.

exception break point 定位在

- (void)resetCanvasConnectionsEffect

中的

[self.canvas addConstraints:canvasConnectionConstraints];

Uploading QQ20151028-1@2x.png…

在AutoLayout布局下的疑问

CAlayer 层是不支持AutoLayout 一般用Frame 或者bounds 来计算大小 但是Autolayout布局确定的时机不对 如何读出正确的frame ViewController 有个 -viewDidLayoutSubviewS 方法

那么问题来了 View怎么读?

There is a difference of function from FDStackView to UIStackView. “- (void)insertArrangedSubview:(UIView *)view atIndex:(NSUInteger)stackIndex” /

In UIStackView :
/*
Adds the view as a subview of the container if it isn't already.
Updates the stack index (but not the subview index) of the
arranged subview if it's already in the arrangedSubviews list.
*/

  • (void)insertArrangedSubview:(UIView *)view atIndex:(NSUInteger)stackIndex;

But FDStackView can not update it.

So that I have to treate the function differently.

Crash in iOS 8 when remove a view from UIStackView

状况如下:

  1. iOS 8 模拟器
  2. StoryBoard 布局好了,一个StackView上有3个等长Button
  3. 在ViewController viewDidLoad/viewDidAppear 时,将一个按钮 removeFromSuperView
    崩溃~
    iOS 9下没问题~

以下Log

2016-06-21 15:40:41.868 Mingdao[73952:20315626] The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x7f00c1d0 UIButton:0x79ecc510.leading == UIButton:0x7abcd710.trailing>
When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView _viewHierarchyUnpreparedForConstraint:] to debug.
2016-06-21 15:40:41.868 Mingdao[73952:20315626] *** Assertion failure in -[UIStackView _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:], /SourceCache/UIKit_Sim/UIKit-3347.44.2/NSLayoutConstraint_UIKitAdditions.m:560
2016-06-21 15:40:41.881 Mingdao[73952:20315626] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Impossible to set up layout with view hierarchy unprepared for constraint.'
*** First throw call stack:
(
0 CoreFoundation 0x01498746 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x04524a97 objc_exception_throw + 44
2 CoreFoundation 0x014985da +[NSException raise:format:arguments:] + 138
3 Foundation 0x01f75720 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 118
4 UIKit 0x032f22c1 __120-[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:]_block_invoke_2 + 203
5 UIKit 0x032f2184 -[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 394
6 UIKit 0x032f2507 -[UIView(UIConstraintBasedLayout) _tryToAddConstraintWithoutUpdatingConstraintsArray:roundingAdjustment:mutuallyExclusiveConstraints:] + 61
7 UIKit 0x032f265c -[UIView(UIConstraintBasedLayout) _tryToAddConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 281
8 UIKit 0x032f2854 -[UIView(UIConstraintBasedLayout) nsli_addConstraint:] + 56
9 UIKit 0x032f2814 -[UIView(UIConstraintBasedLayout) _addConstraint:] + 218
10 UIKit 0x032f2735 -[UIView(UIConstraintBasedLayout) addConstraint:] + 40
11 Mingdao 0x005555a0 -[FDStackViewDistributionLayoutArrangement resetFillEffect] + 1632
12 Mingdao 0x00557589 -[FDStackViewDistributionLayoutArrangement resetAllConstraints] + 73
13 Mingdao 0x00557b3d -[FDStackViewDistributionLayoutArrangement updateCanvasConnectionConstraintsIfNecessary] + 45
14 Mingdao 0x0055893d -[FDStackViewLayoutArrangement updateArrangementConstraints] + 45
15 Mingdao 0x0055076d -[FDStackView updateLayoutArrangements] + 221
16 Mingdao 0x00550800 -[FDStackView updateConstraints] + 48
17 UIKit 0x032ff5a4 -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 300
18 UIKit 0x032ff804 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 127
19 UIKit 0x032ff77f __UIViewRecursionHelper + 41
20 CoreFoundation 0x0138b529 CFArrayApplyFunction + 57
21 UIKit 0x032ff527 -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 175
22 UIKit 0x032ff804 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 127
23 UIKit 0x032ff77f __UIViewRecursionHelper + 41
24 CoreFoundation 0x0138b529 CFArrayApplyFunction + 57
25 UIKit 0x032ff527 -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 175
26 UIKit 0x032ff837 __125-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:]_block_invoke + 43
27 Foundation 0x01ef1077 -[NSISEngine withBehaviors:performModifications:] + 150
28 Foundation 0x01ef45cf -[NSISEngine withAutomaticOptimizationDisabled:] + 48
29 UIKit 0x032fefab -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 64
30 UIKit 0x032ff804 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 127
31 UIKit 0x032ffd96 __60-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded]_block_invoke + 105
32 Foundation 0x01ef1077 -[NSISEngine withBehaviors:performModifications:] + 150
33 Foundation 0x01ef45cf -[NSISEngine withAutomaticOptimizationDisabled:] + 48
34 UIKit 0x032fefab -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 64
35 UIKit 0x032ff9ec -[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded] + 248
36 UIKit 0x0330024d -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeeded] + 191
37 UIKit 0x02c0adaf -[UIView(Hierarchy) layoutBelowIfNeeded] + 393
38 UIKit 0x02c0ac11 -[UIView(Hierarchy) layoutIfNeeded] + 83
39 UIKit 0x02d22bc5 -[UINavigationController _layoutViewController:] + 1154
40 UIKit 0x02d21d41 -[UINavigationController _layoutTopViewController] + 261
41 UIKit 0x02d26fd9 -[UINavigationController _tabBarControllerDidFinishShowingTabBar:isHidden:] + 164
42 UIKit 0x02d377d0 -[UITabBarController animationDidStop:finished:context:] + 218
43 UIKit 0x02d38771 __56-[UITabBarController _hideBarWithTransition:isExplicit:]_block_invoke503 + 267
44 UIKit 0x033f3f0b -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] + 198
45 UIKit 0x033f05c0 -[_UIViewControllerTransitionContext _runAlongsideCompletions] + 122
46 UIKit 0x033f02dc -[_UIViewControllerTransitionContext completeTransition:] + 142
47 UIKit 0x02b73310 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke93 + 724
48 UIKit 0x02c1096e -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 318
49 UIKit 0x02bf4162 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 206
50 UIKit 0x02bf44d2 -[UIViewAnimationState animationDidStop:finished:] + 80
51 QuartzCore 0x02907571 _ZN2CA5Layer23run_animation_callbacksEPv + 307
52 libdispatch.dylib 0x0574ebef _dispatch_client_callout + 14
53 libdispatch.dylib 0x057346bb _dispatch_main_queue_callback_4CF + 993
54 CoreFoundation 0x013f18ee CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 14
55 CoreFoundation 0x013af5f0 __CFRunLoopRun + 2256
56 CoreFoundation 0x013aea5b CFRunLoopRunSpecific + 443
57 CoreFoundation 0x013ae88b CFRunLoopRunInMode + 123
58 GraphicsServices 0x076342c9 GSEventRunModal + 192
59 GraphicsServices 0x07634106 GSEventRun + 104
60 UIKit 0x02b860b6 UIApplicationMain + 1526
61 Mingdao 0x002c86aa main + 138
62 libdyld.dylib 0x05779ac9 start + 1
63 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

iOS 8.3/8.4 phone5/5s/5c 卡顿严重,排渣找到了原因

  • (void)intrinsicContentSizeInvalidatedForChildView:(UIView *)childView {
    [self.distributionArrangement intrinsicContentSizeInvalidatedForItem:childView];
    [self.alignmentArrangement intrinsicContentSizeInvalidatedForItem:childView];
    }
    上面这个更新布局的方法,在iOS7 不会调用,iOS8 会疯狂的调用,会导致界面卡顿很严重,然后注释掉这段代码卡顿消失,界面也没用什么影响,想问下,这个方法的作用?

"H:|-[FDStackView]-(>=5)-|"

on iOS8
"H:|-[FDStackView]-(>=5)-|"
axis=horizontal
alignment=center
distrbution=equal spacing
spacing=5
FDStackView.width = superview.width - 5 (wrong)

but run on iOS9 (using origin UIStackView) is right

Crash in Demo proejct

Use Storyboard mode, add view, remove view, add view then crash:

2015-10-11 14:02:00.085 FDStackViewDemo[6976:177315] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Impossible to set up layout with view hierarchy unprepared for constraint.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000103216f35 exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000102eb1bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000103216d9a +[NSException raise:format:arguments:] + 106
3 Foundation 0x0000000102acf5df -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 UIKit 0x000000010412bcf2 __120-[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:]_block_invoke_2 + 177
5 UIKit 0x000000010412bbe7 -[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 377
6 UIKit 0x000000010412bea4 -[UIView(UIConstraintBasedLayout) _tryToAddConstraintWithoutUpdatingConstraintsArray:roundingAdjustment:mutuallyExclusiveConstraints:] + 30
7 UIKit 0x000000010412bfcc -[UIView(UIConstraintBasedLayout) _tryToAddConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 243
8 FDStackViewDemo 0x0000000102967e66 -[FDStackViewDistributionLayoutArrangement resetFillEffect] + 1750
9 FDStackViewDemo 0x0000000102969979 -[FDStackViewDistributionLayoutArrangement resetAllConstraints] + 57
10 FDStackViewDemo 0x0000000102969ecb -[FDStackViewDistributionLayoutArrangement updateCanvasConnectionConstraintsIfNecessary] + 43
11 FDStackViewDemo 0x000000010296a57b -[FDStackViewLayoutArrangement updateArrangementConstraints] + 43
12 FDStackViewDemo 0x000000010296658a -[FDStackView updateLayoutArrangements] + 186
13 FDStackViewDemo 0x0000000102965bd5 -[FDStackView addArrangedSubview:] + 501
14 FDStackViewDemo 0x000000010296f40b -[FDStoryboardBasedViewController addAction:] + 779
15 UIKit 0x0000000103ab28be -[UIApplication sendAction:to:from:forEvent:] + 75
16 UIKit 0x0000000103bb9410 -[UIControl _sendActionsForEvents:withEvent:] + 467
17 UIKit 0x0000000103bb87df -[UIControl touchesEnded:withEvent:] + 522
18 UIKit 0x0000000103e5f540 _UIGestureRecognizerUpdate + 9487
19 UIKit 0x0000000103af7ff6 -[UIWindow _sendGesturesForEvent:] + 1041
20 UIKit 0x0000000103af8c23 -[UIWindow sendEvent:] + 667
21 UIKit 0x0000000103ac59b1 -[UIApplication sendEvent:] + 246
22 UIKit 0x0000000103ad2a7d _UIApplicationHandleEventFromQueueEvent + 17370
23 UIKit 0x0000000103aae103 _UIApplicationHandleEventQueue + 1961
24 CoreFoundation 0x000000010314c551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION
+ 17
25 CoreFoundation 0x000000010314241d __CFRunLoopDoSources0 + 269
26 CoreFoundation 0x0000000103141a54 __CFRunLoopRun + 868
27 CoreFoundation 0x0000000103141486 CFRunLoopRunSpecific + 470
28 GraphicsServices 0x00000001073959f0 GSEventRunModal + 161
29 UIKit 0x0000000103ab1420 UIApplicationMain + 1282
30 FDStackViewDemo 0x000000010296a7ff main + 111
31 libdyld.dylib 0x0000000105c3e145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

ios7进入页面直接crash。

信息如下:
[NSConcreteMapTable fd_allObjects]: unrecognized selector sent to instance 0x1583bdb0
0x2f7f2159 CFArrayApplyFunction + 36
14 UIKit 0x3267c285 + 144
15 UIKit 0x321e422b + 126
16 CoreFoundation 0x2f7f2159 CFArrayApplyFunction + 36
17 UIKit 0x3267c285 + 144
18 UIKit 0x321e422b + 126
19 CoreFoundation 0x2f7f2159 CFArrayApplyFunction + 36
20 UIKit 0x3267c285 + 144
21 UIKit 0x321e422b + 126
22 CoreFoundation 0x2f7f2159 CFArrayApplyFunction + 36
23 UIKit 0x3267c285 + 144
24 UIKit 0x321e422b + 126
25 CoreFoundation 0x2f7f2159 CFArrayApplyFunction + 36
26 UIKit 0x3267c285 + 144
27 UIKit 0x321e422b + 126
28 CoreFoundation 0x2f7f2159 CFArrayApplyFunction + 36
29 UIKit 0x3267c285 + 144
30 UIKit 0x321e422b + 126
31 CoreFoundation 0x2f7f2159 CFArrayApplyFunction + 36
32 UIKit 0x3267c285 + 144
33 UIKit 0x321e422b + 126
34 CoreFoundation 0x2f7f2159 CFArrayApplyFunction + 36
35 UIKit 0x3267c285 + 144
36 UIKit 0x321e422b + 126
37 CoreFoundation 0x2f7f2159 CFArrayApplyFunction + 36
38 UIKit 0x3267c285 + 144
39 UIKit 0x321e422b + 126
40 Foundation 0x30225d33 + 210
41 UIKit 0x321fe0c7 + 218
42 UIKit 0x320f0543 + 54
43 UIKit 0x32229f03 + 1686
44 UIKit 0x320f02e5 + 380
45 QuartzCore 0x31d6c31b + 142
46 QuartzCore 0x31d67b3f + 350
47 QuartzCore 0x31d679d1 + 16
48 QuartzCore 0x31d673e5 + 228
49 QuartzCore 0x31d671f7 + 314
50 QuartzCore 0x31d60f1d + 56
51 CoreFoundation 0x2f889ff9 + 20
52 CoreFoundation 0x2f887987 + 286
53 CoreFoundation 0x2f887cd3 + 738
54 CoreFoundation 0x2f7f2729 CFRunLoopRunSpecific + 524
55 CoreFoundation 0x2f7f250b CFRunLoopRunInMode + 106
56 GraphicsServices 0x347616d3 GSEventRunModal + 138
57 UIKit 0x32153871 UIApplicationMain + 1136
58 YWArt 0x00178257 main + 106
59 libdyld.dylib

Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named UIStoryboardShowSegueTemplate'

在项目设定支持到iOS7时,storyboard中controller的build for选择iOS9.0 and later,这种情况下当使用storyboard instantiateViewControllerWithIdentifier:@"XXXXX"或者instantiateInitialViewController取得视图控制器时,会报Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named UIStoryboardShowSegueTemplate错误,工程直接挂掉,而其他没有使用stackView没有改变build for这个选项的storyboard则不会有这种问题

addArrangedSubview逻辑错误

stackView依次有4个arrangedSubview:view1red,view2yellow,view3green,view4orange

在系统方法中再次调用[stackView addArrangedSubview:view2yellow];view2yellow会被移动到最后面,view顺序变成view1red,view3green,view4orange,view2yellow

但是在iOS8 FDStackView中view2yellow的位置不会变动。

iOS11新增功能提供

系统新增了下面几个Api有没有计划提供

  • (void)setCustomSpacing:(CGFloat)spacing afterView:(UIView *)arrangedSubview API_AVAILABLE(ios(11.0),tvos(11.0));
  • (CGFloat)customSpacingAfterView:(UIView *)arrangedSubview API_AVAILABLE(ios(11.0),tvos(11.0));

crash

iPhone5s iOS 8.4:add-remove-add-> crash

真机上不起作用,模拟器上起作用。

使用步骤:
1、项目中导入了FDStackView;
2、然后在一个xib文件中添加了一个StackView (已经正确添加约束)
3、在步骤2中创建的StackView中添加4个按钮,StackView的相关属性设置为:
Axis: Horizontal
Alignment: Center
Distribution: Equal Spacing
Spacing: 0

结果:
在iPhone6 iOS8.2 和 iPhone5 iOS9.1 真机上�只显示前三个按钮。
在对应的模拟器上正常。
请问是我哪里设置错误了吗?

iOS8系统下部分情况下卡顿问题

(void)intrinsicContentSizeInvalidatedForChildView:(UIView *)childView {
[self.distributionArrangement intrinsicContentSizeInvalidatedForItem:childView];
[self.alignmentArrangement intrinsicContentSizeInvalidatedForItem:childView];
}

方法名很明确指出需要无效化传进去的childView的intrinsicSize,但是方法全程内部并没有用到childView而是对整个stackView重新布局了,以至于只要stackView有一些小改动,整个stackView都要跟着刷新,如果stackView里有两个childView需要更新,根据代码逻辑,刷新就会调用两次,这性能损耗非常大,目前我已应用在UITableViewCell的布局中,Cell上如果需要设置多个文本时滚动卡顿非常明显(iOS8下)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.