Skip to content

Commit

Permalink
Added convience method to count number of side controllers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Inferis committed Apr 25, 2013
1 parent 5173225 commit 0960a04
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ViewDeck/IIViewDeckController.m
Expand Up @@ -180,6 +180,7 @@ @interface IIViewDeckController () <UIGestureRecognizerDelegate>
@property (nonatomic, readonly) UIView* slidingControllerView;

- (void)cleanup;
- (uint)sideControllerCount;

- (CGRect)slidingRectForOffset:(CGFloat)offset forOrientation:(IIViewDeckOffsetOrientation)orientation;
- (CGSize)slidingSizeForOffset:(CGFloat)offset forOrientation:(IIViewDeckOffsetOrientation)orientation;
Expand Down Expand Up @@ -446,6 +447,10 @@ - (void)didReceiveMemoryWarning

#pragma mark - Bookkeeping

- (uint)sideControllerCount {
return (self.leftController ? 1 : 0) + (self.rightController ? 1 : 0) + (self.topController ? 1 : 0) + (self.bottomController ? 1 : 0);
}

- (NSArray*)controllers {
NSMutableArray *result = [NSMutableArray array];
if (self.centerController) [result addObject:self.centerController];
Expand Down Expand Up @@ -734,9 +739,7 @@ - (void)setMaxSize:(CGFloat)maxSize {
}

- (void)setMaxSize:(CGFloat)maxSize completion:(void(^)(BOOL finished))completion {
int count = (self.leftController ? 1 : 0) + (self.rightController ? 1 : 0) + (self.topController ? 1 : 0) + (self.bottomController ? 1 : 0);

if (count > 1) {
if ([self sideControllerCount] > 1) {
NSLog(@"IIViewDeckController: warning: setting maxLedge with more than one side controllers. Value will be ignored.");
return;
}
Expand Down

0 comments on commit 0960a04

Please sign in to comment.