Visitar URL original
Fixed crash when setting ORStackView.bottomMarginHeight without any c… · orta/ORStackView@e3d708f · GitHub
Skip to content

Commit e3d708f

Browse files
committed
Fixed crash when setting ORStackView.bottomMarginHeight without any child views on iOS8.
1 parent f93a9bf commit e3d708f

5 files changed

Lines changed: 45 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ORStackView CHANGELOG
22

3+
## Next
4+
5+
* Fixed crash when setting ORStackView.bottomMarginHeight without any child views on iOS8 - @dblock
6+
37
## 1.2.0
48

59
* Added ORSplitStackView - @1aurabrown
@@ -16,4 +20,4 @@
1620
* Stacking views
1721
* Stacking views that uses view tags to automatically set the order
1822
* UIScrollView subclass that handles having a stack set up for you
19-
* API for UIViewControllers
23+
* API for UIViewControllers

‎Classes/ios/ORStackView.m‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ - (void)updateConstraints
6868

6969
if (self.bottomMarginHeight != NSNotFound) {
7070
[self removeConstraint:self.bottomConstraint];
71-
72-
NSString *constraint = [NSString stringWithFormat:@"%0.0f", self.bottomMarginHeight];
7371
UIView *lastView = self.lastView;
74-
self.bottomConstraint = [[self alignBottomEdgeWithView:lastView predicate:constraint] lastObject];
72+
if (self.lastView) {
73+
NSString *constraint = [NSString stringWithFormat:@"%0.0f", self.bottomMarginHeight];
74+
self.bottomConstraint = [[self alignBottomEdgeWithView:lastView predicate:constraint] lastObject];
75+
}
7576
}
7677

7778
[super updateConstraints];

‎ORStackViewExample.xcodeproj/project.pbxproj‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
3C9C9552194250CD00DEA440 /* ORFifthViewControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C9C9551194250CD00DEA440 /* ORFifthViewControllerTests.m */; };
1717
3C9C9554194259D300DEA440 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C9C9553194259D300DEA440 /* Foundation.framework */; };
1818
3C9C9556194259DB00DEA440 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C9C9555194259DB00DEA440 /* UIKit.framework */; };
19+
3C9C955A1942661500DEA440 /* ORStackViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C9C95591942661500DEA440 /* ORStackViewTests.m */; };
1920
3CC74D78194245AC0069A97D /* ORFirstViewControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CC74D77194245AC0069A97D /* ORFirstViewControllerTests.m */; };
2021
604D943217BCD45900E331B1 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 604D943017BCD45900E331B1 /* InfoPlist.strings */; };
2122
604D943417BCD45900E331B1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 604D943317BCD45900E331B1 /* main.m */; };
@@ -58,6 +59,7 @@
5859
3C9C9553194259D300DEA440 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
5960
3C9C9555194259DB00DEA440 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
6061
3C9C955719425CB200DEA440 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = SDKROOT; };
62+
3C9C95591942661500DEA440 /* ORStackViewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ORStackViewTests.m; sourceTree = "<group>"; };
6163
3CC74D73194245AC0069A97D /* ORStackViewExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ORStackViewExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
6264
3CC74D76194245AC0069A97D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6365
3CC74D77194245AC0069A97D /* ORFirstViewControllerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ORFirstViewControllerTests.m; sourceTree = "<group>"; };
@@ -121,6 +123,7 @@
121123
3C9C954D194250B500DEA440 /* ORThirdViewControllerTests.m */,
122124
3C9C954F194250C100DEA440 /* ORFourthViewControllerTests.m */,
123125
3C9C9551194250CD00DEA440 /* ORFifthViewControllerTests.m */,
126+
3C9C95591942661500DEA440 /* ORStackViewTests.m */,
124127
);
125128
path = ORStackViewExampleTests;
126129
sourceTree = "<group>";
@@ -388,6 +391,7 @@
388391
3CC74D78194245AC0069A97D /* ORFirstViewControllerTests.m in Sources */,
389392
3C9C9552194250CD00DEA440 /* ORFifthViewControllerTests.m in Sources */,
390393
3C9C9550194250C100DEA440 /* ORFourthViewControllerTests.m in Sources */,
394+
3C9C955A1942661500DEA440 /* ORStackViewTests.m in Sources */,
391395
3C9C954A1942502A00DEA440 /* ORColorView+DebugColours.m in Sources */,
392396
);
393397
runOnlyForDeploymentPostprocessing = 0;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// OREmptyViewControllerTests.m
3+
// ORStackViewExample
4+
//
5+
// Created by Daniel Doubrovkine on 6/6/14.
6+
// Copyright (c) 2014 Orta. All rights reserved.
7+
//
8+
9+
#import <ORStackView/ORStackView.h>
10+
11+
SpecBegin(ORStackView)
12+
13+
__block UIWindow *window;
14+
15+
beforeEach(^{
16+
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
17+
});
18+
19+
describe(@"bottomMarginHeight", ^{
20+
it(@"works with an empty stack view", ^{
21+
UIViewController *vc = [[UIViewController alloc] init];
22+
window.rootViewController = vc;
23+
ORStackView *view = [[ORStackView alloc] initWithFrame:vc.view.bounds];
24+
view.bottomMarginHeight = 10;
25+
[vc.view addSubview:view];
26+
[view setNeedsUpdateConstraints];
27+
[window makeKeyAndVisible];
28+
expect(window).will.haveValidSnapshotNamed(@"bottomMarginHeightWithEmptyStackView");
29+
});
30+
});
31+
32+
SpecEnd
10.6 KB
Loading

0 commit comments

Comments
 (0)