Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Classes/ios/ORStackViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// ORStackViewController.h
// Pods
//
// Created by Dzianis Lebedzeu on 5/5/15.
//
//

#import "ORStackScrollView.h"

@interface ORStackViewController : UIViewController

@property (nonatomic, readonly) ORStackScrollView *scrollView;
@property (nonatomic, readonly) ORStackView *stackView;

@end
30 changes: 30 additions & 0 deletions Classes/ios/ORStackViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// ORStackViewController.m
// Pods
//
// Created by Dzianis Lebedzeu on 5/5/15.
//
//

#import "ORStackViewController.h"

@implementation ORStackViewController

- (void)loadView {
self.view = [[ORStackScrollView alloc] init];
}

- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
self.scrollView.contentInset = UIEdgeInsetsMake(self.topLayoutGuide.length, 0, self.bottomLayoutGuide.length, 0);
}

- (ORStackScrollView *)scrollView {
return (ORStackScrollView *)self.view;
}

- (ORStackView *)stackView {
return self.scrollView.stackView;
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this automate some of the top layout guide?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how it should be handled inside ORStackViewController, for example, for handling bottom bar in this PR I've used self.edgesForExtendedLayout = UIRectEdgeNone; inside sibling view controller and I thought it was correct approach of doing this. (at least I've did this for UITableViewController and it worked as expected)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, this makes sense. 👯

@end
4 changes: 3 additions & 1 deletion ORStackViewExample/ORSecondViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright (c) 2013 Orta. All rights reserved.
//

@interface ORSecondViewController : UIViewController
#import <ORStackView/ORStackViewController.h>

@interface ORSecondViewController : ORStackViewController

@end
18 changes: 1 addition & 17 deletions ORStackViewExample/ORSecondViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,14 @@

// More complex use case: Inserting

@interface ORSecondViewController ()
@property (nonatomic, strong) ORStackView *stackView;
@end

@implementation ORSecondViewController

- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}

- (void)loadView
{
self.view = [[UIView alloc] init];
}

- (void)viewDidLoad
{
self.stackView = [[ORStackView alloc] init];
[self.view addSubview:self.stackView];
if ([self respondsToSelector:@selector(topLayoutGuide)]) {
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.stackView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.topLayoutGuide attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]];
}
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.stackView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.stackView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];

ORColourView *view1 = [[ORColourView alloc] init];
view1.text = @"1 - ORStackView - Tap Me";
view1.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 40};
Expand Down Expand Up @@ -76,4 +59,5 @@ - (void)removeTappedView:(UITapGestureRecognizer *)gesture
{
[self.stackView removeSubview:gesture.view];
}

@end