project_files/HedgewarsMobile/Classes/MGSplitViewController/MGSplitViewController.m
author koda
Sat, 26 Jan 2013 23:57:37 +0100
changeset 8441 a00b0fa0dbd7
parent 6908 896ed2afcfb8
child 11115 3729ac42189b
permissions -rwxr-xr-x
some whitespaces from ios files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
     1
//
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
     2
//  MGSplitViewController.m
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
     3
//  MGSplitView
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
     4
//
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
     5
//  Created by Matt Gemmell on 26/07/2010.
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
     6
//  Copyright 2010 Instinctive Code.
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
     7
//
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
     8
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
     9
#import "MGSplitViewController.h"
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    10
#import "MGSplitDividerView.h"
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    11
#import "MGSplitCornersView.h"
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    12
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    13
#define MG_DEFAULT_SPLIT_POSITION       320.0   // default width of master view in UISplitViewController.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    14
#define MG_DEFAULT_SPLIT_WIDTH          1.0     // default width of split-gutter in UISplitViewController.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    15
#define MG_DEFAULT_CORNER_RADIUS        5.0     // default corner-radius of overlapping split-inner corners on the master and detail views.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    16
#define MG_DEFAULT_CORNER_COLOR         [UIColor blackColor]    // default color of intruding inner corners (and divider background).
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    17
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    18
#define MG_PANESPLITTER_CORNER_RADIUS   0.0     // corner-radius of split-inner corners for MGSplitViewDividerStylePaneSplitter style.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    19
#define MG_PANESPLITTER_SPLIT_WIDTH     25.0    // width of split-gutter for MGSplitViewDividerStylePaneSplitter style.
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    20
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    21
#define MG_MIN_VIEW_WIDTH               200.0   // minimum width a view is allowed to become as a result of changing the splitPosition.
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    22
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    23
#define MG_ANIMATION_CHANGE_SPLIT_ORIENTATION   @"ChangeSplitOrientation"   // Animation ID for internal use.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    24
#define MG_ANIMATION_CHANGE_SUBVIEWS_ORDER      @"ChangeSubviewsOrder"  // Animation ID for internal use.
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    25
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    26
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    27
@interface MGSplitViewController (MGPrivateMethods)
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    28
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    29
- (void)setup;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    30
- (CGSize)splitViewSizeForOrientation:(UIInterfaceOrientation)theOrientation;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    31
- (void)layoutSubviews;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    32
- (void)layoutSubviewsWithAnimation:(BOOL)animate;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    33
- (void)layoutSubviewsForInterfaceOrientation:(UIInterfaceOrientation)theOrientation withAnimation:(BOOL)animate;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    34
- (BOOL)shouldShowMasterForInterfaceOrientation:(UIInterfaceOrientation)theOrientation;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    35
- (BOOL)shouldShowMaster;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    36
- (NSString *)nameOfInterfaceOrientation:(UIInterfaceOrientation)theOrientation;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    37
- (void)reconfigureForMasterInPopover:(BOOL)inPopover;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    38
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    39
@end
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    40
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    41
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    42
@implementation MGSplitViewController
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    43
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    44
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    45
#pragma mark -
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    46
#pragma mark Orientation helpers
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    47
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    48
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    49
- (NSString *)nameOfInterfaceOrientation:(UIInterfaceOrientation)theOrientation
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    50
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    51
    NSString *orientationName = nil;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    52
    switch (theOrientation) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    53
        case UIInterfaceOrientationPortrait:
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    54
            orientationName = @"Portrait"; // Home button at bottom
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    55
            break;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    56
        case UIInterfaceOrientationPortraitUpsideDown:
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    57
            orientationName = @"Portrait (Upside Down)"; // Home button at top
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    58
            break;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    59
        case UIInterfaceOrientationLandscapeLeft:
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    60
            orientationName = @"Landscape (Left)"; // Home button on left
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    61
            break;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    62
        case UIInterfaceOrientationLandscapeRight:
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    63
            orientationName = @"Landscape (Right)"; // Home button on right
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    64
            break;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    65
        default:
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    66
            break;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    67
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    68
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    69
    return orientationName;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    70
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    71
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    72
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    73
- (BOOL)isLandscape
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    74
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    75
    return UIInterfaceOrientationIsLandscape(self.interfaceOrientation);
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    76
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    77
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    78
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    79
- (BOOL)shouldShowMasterForInterfaceOrientation:(UIInterfaceOrientation)theOrientation
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    80
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    81
    // Returns YES if master view should be shown directly embedded in the splitview, instead of hidden in a popover.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    82
    return ((UIInterfaceOrientationIsLandscape(theOrientation)) ? _showsMasterInLandscape : _showsMasterInPortrait);
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    83
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    84
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    85
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    86
- (BOOL)shouldShowMaster
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    87
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    88
    return [self shouldShowMasterForInterfaceOrientation:self.interfaceOrientation];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    89
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    90
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    91
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    92
- (BOOL)isShowingMaster
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    93
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
    94
    return [self shouldShowMaster] && self.masterViewController && self.masterViewController.view && ([self.masterViewController.view superview] == self.view);
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    95
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    96
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    97
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    98
#pragma mark -
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
    99
#pragma mark Setup and Teardown
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   100
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   101
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   102
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   103
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   104
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   105
        [self setup];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   106
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   107
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   108
    return self;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   109
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   110
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   111
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   112
- (id)initWithCoder:(NSCoder *)aDecoder
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   113
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   114
    if ((self = [super initWithCoder:aDecoder])) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   115
        [self setup];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   116
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   117
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   118
    return self;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   119
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   120
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   121
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   122
- (void)setup
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   123
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   124
    // Configure default behaviour.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   125
    _viewControllers = [[NSMutableArray alloc] initWithObjects:[NSNull null], [NSNull null], nil];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   126
    _splitWidth = MG_DEFAULT_SPLIT_WIDTH;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   127
    _showsMasterInPortrait = NO;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   128
    _showsMasterInLandscape = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   129
    _reconfigurePopup = NO;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   130
    _vertical = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   131
    _masterBeforeDetail = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   132
    _splitPosition = MG_DEFAULT_SPLIT_POSITION;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   133
    CGRect divRect = self.view.bounds;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   134
    if ([self isVertical]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   135
        divRect.origin.y = _splitPosition;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   136
        divRect.size.height = _splitWidth;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   137
    } else {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   138
        divRect.origin.x = _splitPosition;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   139
        divRect.size.width = _splitWidth;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   140
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   141
    _dividerView = [[MGSplitDividerView alloc] initWithFrame:divRect];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   142
    _dividerView.splitViewController = self;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   143
    _dividerView.backgroundColor = MG_DEFAULT_CORNER_COLOR;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   144
    _dividerStyle = MGSplitViewDividerStyleThin;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   145
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   146
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   147
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   148
- (void)dealloc
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   149
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   150
    _delegate = nil;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   151
    [self.view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   152
    [_viewControllers release];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   153
    [_barButtonItem release];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   154
    [_hiddenPopoverController release];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   155
    [_dividerView release];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   156
    [_cornerViews release];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   157
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   158
    [super dealloc];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   159
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   160
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   161
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   162
#pragma mark -
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   163
#pragma mark View management
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   164
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   165
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   166
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   167
{
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   168
    return YES;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   169
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   170
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   171
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   172
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   173
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   174
    [self.masterViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   175
    [self.detailViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   176
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   177
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   178
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   179
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   180
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   181
    [self.masterViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   182
    [self.detailViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   183
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   184
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   185
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   186
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   187
                                         duration:(NSTimeInterval)duration
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   188
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   189
    [self.masterViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   190
    [self.detailViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   191
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   192
    // Hide popover.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   193
    if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   194
        [_hiddenPopoverController dismissPopoverAnimated:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   195
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   196
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   197
    // Re-tile views.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   198
    _reconfigurePopup = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   199
    [self layoutSubviewsForInterfaceOrientation:toInterfaceOrientation withAnimation:YES];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   200
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   201
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   202
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   203
- (void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   204
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   205
    [self.masterViewController willAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   206
    [self.detailViewController willAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   207
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   208
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   209
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   210
- (void)didAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   211
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   212
    [self.masterViewController didAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   213
    [self.detailViewController didAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   214
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   215
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   216
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   217
- (void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   218
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   219
    [self.masterViewController willAnimateSecondHalfOfRotationFromInterfaceOrientation:fromInterfaceOrientation duration:duration];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   220
    [self.detailViewController willAnimateSecondHalfOfRotationFromInterfaceOrientation:fromInterfaceOrientation duration:duration];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   221
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   222
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   223
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   224
- (CGSize)splitViewSizeForOrientation:(UIInterfaceOrientation)theOrientation
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   225
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   226
    UIScreen *screen = [UIScreen mainScreen];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   227
    CGRect fullScreenRect = screen.bounds; // always implicitly in Portrait orientation.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   228
    CGRect appFrame = screen.applicationFrame;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   229
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   230
    // Find status bar height by checking which dimension of the applicationFrame is narrower than screen bounds.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   231
    // Little bit ugly looking, but it'll still work even if they change the status bar height in future.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   232
    float statusBarHeight = MAX((fullScreenRect.size.width - appFrame.size.width), (fullScreenRect.size.height - appFrame.size.height));
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   233
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   234
    // Initially assume portrait orientation.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   235
    float width = fullScreenRect.size.width;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   236
    float height = fullScreenRect.size.height;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   237
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   238
    // Correct for orientation.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   239
    if (UIInterfaceOrientationIsLandscape(theOrientation)) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   240
        width = height;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   241
        height = fullScreenRect.size.width;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   242
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   243
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   244
    // Account for status bar, which always subtracts from the height (since it's always at the top of the screen).
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   245
    height -= statusBarHeight;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   246
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   247
    return CGSizeMake(width, height);
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   248
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   249
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   250
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   251
- (void)layoutSubviewsForInterfaceOrientation:(UIInterfaceOrientation)theOrientation withAnimation:(BOOL)animate
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   252
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   253
    if (_reconfigurePopup) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   254
        [self reconfigureForMasterInPopover:![self shouldShowMasterForInterfaceOrientation:theOrientation]];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   255
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   256
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   257
    // Layout the master, detail and divider views appropriately, adding/removing subviews as needed.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   258
    // First obtain relevant geometry.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   259
    CGSize fullSize = [self splitViewSizeForOrientation:theOrientation];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   260
    float width = fullSize.width;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   261
    float height = fullSize.height;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   262
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   263
    if (NO) { // Just for debugging.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   264
        NSLog(@"Target orientation is %@, dimensions will be %.0f x %.0f",
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   265
              [self nameOfInterfaceOrientation:theOrientation], width, height);
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   266
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   267
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   268
    // Layout the master, divider and detail views.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   269
    CGRect newFrame = CGRectMake(0, 0, width, height);
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   270
    UIViewController *controller;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   271
    UIView *theView;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   272
    BOOL shouldShowMaster = [self shouldShowMasterForInterfaceOrientation:theOrientation];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   273
    BOOL masterFirst = [self isMasterBeforeDetail];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   274
    if ([self isVertical]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   275
        // Master on left, detail on right (or vice versa).
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   276
        CGRect masterRect, dividerRect, detailRect;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   277
        if (masterFirst) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   278
            if (!shouldShowMaster) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   279
                // Move off-screen.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   280
                newFrame.origin.x -= (_splitPosition + _splitWidth);
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   281
            }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   282
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   283
            newFrame.size.width = _splitPosition;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   284
            masterRect = newFrame;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   285
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   286
            newFrame.origin.x += newFrame.size.width;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   287
            newFrame.size.width = _splitWidth;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   288
            dividerRect = newFrame;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   289
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   290
            newFrame.origin.x += newFrame.size.width;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   291
            newFrame.size.width = width - newFrame.origin.x;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   292
            detailRect = newFrame;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   293
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   294
        } else {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   295
            if (!shouldShowMaster) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   296
                // Move off-screen.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   297
                newFrame.size.width += (_splitPosition + _splitWidth);
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   298
            }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   299
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   300
            newFrame.size.width -= (_splitPosition + _splitWidth);
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   301
            detailRect = newFrame;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   302
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   303
            newFrame.origin.x += newFrame.size.width;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   304
            newFrame.size.width = _splitWidth;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   305
            dividerRect = newFrame;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   306
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   307
            newFrame.origin.x += newFrame.size.width;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   308
            newFrame.size.width = _splitPosition;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   309
            masterRect = newFrame;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   310
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   311
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   312
        // Position master.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   313
        controller = self.masterViewController;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   314
        if (controller && [controller isKindOfClass:[UIViewController class]])  {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   315
            theView = controller.view;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   316
            if (theView) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   317
                theView.frame = masterRect;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   318
                if (!theView.superview) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   319
                    [controller viewWillAppear:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   320
                    [self.view addSubview:theView];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   321
                    [controller viewDidAppear:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   322
                }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   323
            }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   324
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   325
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   326
        // Position divider.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   327
        theView = _dividerView;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   328
        theView.frame = dividerRect;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   329
        if (!theView.superview) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   330
            [self.view addSubview:theView];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   331
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   332
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   333
        // Position detail.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   334
        controller = self.detailViewController;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   335
        if (controller && [controller isKindOfClass:[UIViewController class]])  {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   336
            theView = controller.view;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   337
            if (theView) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   338
                theView.frame = detailRect;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   339
                if (!theView.superview) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   340
                    [self.view insertSubview:theView aboveSubview:self.masterViewController.view];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   341
                } else {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   342
                    [self.view bringSubviewToFront:theView];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   343
                }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   344
            }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   345
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   346
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   347
    } else {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   348
        // Master above, detail below (or vice versa).
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   349
        CGRect masterRect, dividerRect, detailRect;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   350
        if (masterFirst) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   351
            if (!shouldShowMaster) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   352
                // Move off-screen.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   353
                newFrame.origin.y -= (_splitPosition + _splitWidth);
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   354
            }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   355
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   356
            newFrame.size.height = _splitPosition;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   357
            masterRect = newFrame;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   358
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   359
            newFrame.origin.y += newFrame.size.height;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   360
            newFrame.size.height = _splitWidth;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   361
            dividerRect = newFrame;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   362
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   363
            newFrame.origin.y += newFrame.size.height;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   364
            newFrame.size.height = height - newFrame.origin.y;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   365
            detailRect = newFrame;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   366
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   367
        } else {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   368
            if (!shouldShowMaster) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   369
                // Move off-screen.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   370
                newFrame.size.height += (_splitPosition + _splitWidth);
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   371
            }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   372
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   373
            newFrame.size.height -= (_splitPosition + _splitWidth);
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   374
            detailRect = newFrame;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   375
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   376
            newFrame.origin.y += newFrame.size.height;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   377
            newFrame.size.height = _splitWidth;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   378
            dividerRect = newFrame;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   379
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   380
            newFrame.origin.y += newFrame.size.height;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   381
            newFrame.size.height = _splitPosition;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   382
            masterRect = newFrame;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   383
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   384
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   385
        // Position master.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   386
        controller = self.masterViewController;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   387
        if (controller && [controller isKindOfClass:[UIViewController class]])  {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   388
            theView = controller.view;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   389
            if (theView) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   390
                theView.frame = masterRect;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   391
                if (!theView.superview) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   392
                    [controller viewWillAppear:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   393
                    [self.view addSubview:theView];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   394
                    [controller viewDidAppear:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   395
                }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   396
            }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   397
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   398
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   399
        // Position divider.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   400
        theView = _dividerView;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   401
        theView.frame = dividerRect;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   402
        if (!theView.superview) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   403
            [self.view addSubview:theView];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   404
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   405
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   406
        // Position detail.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   407
        controller = self.detailViewController;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   408
        if (controller && [controller isKindOfClass:[UIViewController class]])  {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   409
            theView = controller.view;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   410
            if (theView) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   411
                theView.frame = detailRect;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   412
                if (!theView.superview) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   413
                    [self.view insertSubview:theView aboveSubview:self.masterViewController.view];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   414
                } else {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   415
                    [self.view bringSubviewToFront:theView];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   416
                }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   417
            }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   418
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   419
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   420
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   421
    // Create corner views if necessary.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   422
    MGSplitCornersView *leadingCorners; // top/left of screen in vertical/horizontal split.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   423
    MGSplitCornersView *trailingCorners; // bottom/right of screen in vertical/horizontal split.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   424
    if (!_cornerViews) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   425
        CGRect cornerRect = CGRectMake(0, 0, 10, 10); // arbitrary, will be resized below.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   426
        leadingCorners = [[MGSplitCornersView alloc] initWithFrame:cornerRect];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   427
        leadingCorners.splitViewController = self;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   428
        leadingCorners.cornerBackgroundColor = MG_DEFAULT_CORNER_COLOR;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   429
        leadingCorners.cornerRadius = MG_DEFAULT_CORNER_RADIUS;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   430
        trailingCorners = [[MGSplitCornersView alloc] initWithFrame:cornerRect];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   431
        trailingCorners.splitViewController = self;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   432
        trailingCorners.cornerBackgroundColor = MG_DEFAULT_CORNER_COLOR;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   433
        trailingCorners.cornerRadius = MG_DEFAULT_CORNER_RADIUS;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   434
        _cornerViews = [[NSArray alloc] initWithObjects:leadingCorners, trailingCorners, nil];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   435
        [leadingCorners release];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   436
        [trailingCorners release];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   437
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   438
    } else if ([_cornerViews count] == 2) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   439
        leadingCorners = [_cornerViews objectAtIndex:0];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   440
        trailingCorners = [_cornerViews objectAtIndex:1];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   441
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   442
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   443
    // Configure and layout the corner-views.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   444
    leadingCorners.cornersPosition = (_vertical) ? MGCornersPositionLeadingVertical : MGCornersPositionLeadingHorizontal;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   445
    trailingCorners.cornersPosition = (_vertical) ? MGCornersPositionTrailingVertical : MGCornersPositionTrailingHorizontal;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   446
    leadingCorners.autoresizingMask = (_vertical) ? UIViewAutoresizingFlexibleBottomMargin : UIViewAutoresizingFlexibleRightMargin;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   447
    trailingCorners.autoresizingMask = (_vertical) ? UIViewAutoresizingFlexibleTopMargin : UIViewAutoresizingFlexibleLeftMargin;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   448
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   449
    float x, y, cornersWidth, cornersHeight;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   450
    CGRect leadingRect, trailingRect;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   451
    float radius = leadingCorners.cornerRadius;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   452
    if (_vertical) { // left/right split
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   453
        cornersWidth = (radius * 2.0) + _splitWidth;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   454
        cornersHeight = radius;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   455
        x = ((shouldShowMaster) ? ((masterFirst) ? _splitPosition : width - (_splitPosition + _splitWidth)) : (0 - _splitWidth)) - radius;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   456
        y = 0;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   457
        leadingRect = CGRectMake(x, y, cornersWidth, cornersHeight); // top corners
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   458
        trailingRect = CGRectMake(x, (height - cornersHeight), cornersWidth, cornersHeight); // bottom corners
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   459
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   460
    } else { // top/bottom split
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   461
        x = 0;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   462
        y = ((shouldShowMaster) ? ((masterFirst) ? _splitPosition : height - (_splitPosition + _splitWidth)) : (0 - _splitWidth)) - radius;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   463
        cornersWidth = radius;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   464
        cornersHeight = (radius * 2.0) + _splitWidth;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   465
        leadingRect = CGRectMake(x, y, cornersWidth, cornersHeight); // left corners
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   466
        trailingRect = CGRectMake((width - cornersWidth), y, cornersWidth, cornersHeight); // right corners
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   467
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   468
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   469
    leadingCorners.frame = leadingRect;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   470
    trailingCorners.frame = trailingRect;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   471
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   472
    // Ensure corners are visible and frontmost.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   473
    if (!leadingCorners.superview) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   474
        [self.view insertSubview:leadingCorners aboveSubview:self.detailViewController.view];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   475
        [self.view insertSubview:trailingCorners aboveSubview:self.detailViewController.view];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   476
    } else {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   477
        [self.view bringSubviewToFront:leadingCorners];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   478
        [self.view bringSubviewToFront:trailingCorners];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   479
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   480
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   481
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   482
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   483
- (void)layoutSubviewsWithAnimation:(BOOL)animate
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   484
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   485
    [self layoutSubviewsForInterfaceOrientation:self.interfaceOrientation withAnimation:animate];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   486
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   487
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   488
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   489
- (void)layoutSubviews
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   490
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   491
    [self layoutSubviewsForInterfaceOrientation:self.interfaceOrientation withAnimation:YES];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   492
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   493
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   494
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   495
- (void)viewWillAppear:(BOOL)animated
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   496
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   497
    [super viewWillAppear:animated];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   498
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   499
    if ([self isShowingMaster]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   500
        [self.masterViewController viewWillAppear:animated];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   501
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   502
    [self.detailViewController viewWillAppear:animated];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   503
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   504
    _reconfigurePopup = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   505
    [self layoutSubviews];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   506
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   507
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   508
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   509
- (void)viewDidAppear:(BOOL)animated
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   510
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   511
    [super viewDidAppear:animated];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   512
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   513
    if ([self isShowingMaster]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   514
        [self.masterViewController viewDidAppear:animated];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   515
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   516
    [self.detailViewController viewDidAppear:animated];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   517
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   518
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   519
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   520
- (void)viewWillDisappear:(BOOL)animated
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   521
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   522
    [super viewWillDisappear:animated];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   523
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   524
    if ([self isShowingMaster]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   525
        [self.masterViewController viewWillDisappear:animated];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   526
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   527
    [self.detailViewController viewWillDisappear:animated];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   528
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   529
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   530
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   531
- (void)viewDidDisappear:(BOOL)animated
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   532
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   533
    [super viewDidDisappear:animated];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   534
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   535
    if ([self isShowingMaster]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   536
        [self.masterViewController viewDidDisappear:animated];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   537
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   538
    [self.detailViewController viewDidDisappear:animated];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   539
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   540
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   541
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   542
#pragma mark -
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   543
#pragma mark Popover handling
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   544
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   545
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   546
- (void)reconfigureForMasterInPopover:(BOOL)inPopover
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   547
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   548
    _reconfigurePopup = NO;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   549
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   550
    if ((inPopover && _hiddenPopoverController) || (!inPopover && !_hiddenPopoverController) || !self.masterViewController) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   551
        // Nothing to do.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   552
        return;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   553
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   554
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   555
    if (inPopover && !_hiddenPopoverController && !_barButtonItem) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   556
        // Create and configure popover for our masterViewController.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   557
        [_hiddenPopoverController release];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   558
        _hiddenPopoverController = nil;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   559
        [self.masterViewController viewWillDisappear:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   560
        _hiddenPopoverController = [[UIPopoverController alloc] initWithContentViewController:self.masterViewController];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   561
        [self.masterViewController viewDidDisappear:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   562
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   563
        // Create and configure _barButtonItem.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   564
        _barButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Master", nil)
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   565
                                                          style:UIBarButtonItemStyleBordered
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   566
                                                         target:self
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   567
                                                         action:@selector(showMasterPopover:)];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   568
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   569
        // Inform delegate of this state of affairs.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   570
        if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:willHideViewController:withBarButtonItem:forPopoverController:)]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   571
            [(NSObject <MGSplitViewControllerDelegate> *)_delegate splitViewController:self
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   572
                                                                willHideViewController:self.masterViewController
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   573
                                                                     withBarButtonItem:_barButtonItem
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   574
                                                                  forPopoverController:_hiddenPopoverController];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   575
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   576
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   577
    } else if (!inPopover && _hiddenPopoverController && _barButtonItem) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   578
        // I know this looks strange, but it fixes a bizarre issue with UIPopoverController leaving masterViewController's views in disarray.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   579
        [_hiddenPopoverController presentPopoverFromRect:CGRectZero inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   580
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   581
        // Remove master from popover and destroy popover, if it exists.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   582
        [_hiddenPopoverController dismissPopoverAnimated:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   583
        [_hiddenPopoverController release];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   584
        _hiddenPopoverController = nil;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   585
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   586
        // Inform delegate that the _barButtonItem will become invalid.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   587
        if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:willShowViewController:invalidatingBarButtonItem:)]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   588
            [(NSObject <MGSplitViewControllerDelegate> *)_delegate splitViewController:self
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   589
                                                                willShowViewController:self.masterViewController
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   590
                                                             invalidatingBarButtonItem:_barButtonItem];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   591
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   592
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   593
        // Destroy _barButtonItem.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   594
        [_barButtonItem release];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   595
        _barButtonItem = nil;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   596
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   597
        // Move master view.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   598
        UIView *masterView = self.masterViewController.view;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   599
        if (masterView && masterView.superview != self.view) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   600
            [masterView removeFromSuperview];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   601
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   602
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   603
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   604
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   605
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   606
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   607
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   608
    [self reconfigureForMasterInPopover:NO];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   609
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   610
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   611
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   612
- (void)notePopoverDismissed
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   613
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   614
    [self popoverControllerDidDismissPopover:_hiddenPopoverController];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   615
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   616
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   617
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   618
#pragma mark -
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   619
#pragma mark Animations
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   620
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   621
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   622
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   623
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   624
    if (([animationID isEqualToString:MG_ANIMATION_CHANGE_SPLIT_ORIENTATION] ||
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   625
         [animationID isEqualToString:MG_ANIMATION_CHANGE_SUBVIEWS_ORDER])
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   626
        && _cornerViews) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   627
        for (UIView *corner in _cornerViews) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   628
            corner.hidden = NO;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   629
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   630
        _dividerView.hidden = NO;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   631
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   632
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   633
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   634
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   635
#pragma mark -
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   636
#pragma mark IB Actions
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   637
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   638
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   639
- (IBAction)toggleSplitOrientation:(id)sender
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   640
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   641
    BOOL showingMaster = [self isShowingMaster];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   642
    if (showingMaster) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   643
        if (_cornerViews) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   644
            for (UIView *corner in _cornerViews) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   645
                corner.hidden = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   646
            }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   647
            _dividerView.hidden = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   648
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   649
        [UIView beginAnimations:MG_ANIMATION_CHANGE_SPLIT_ORIENTATION context:nil];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   650
        [UIView setAnimationDelegate:self];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   651
        [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   652
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   653
    self.vertical = (!self.vertical);
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   654
    if (showingMaster) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   655
        [UIView commitAnimations];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   656
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   657
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   659
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   660
- (IBAction)toggleMasterBeforeDetail:(id)sender
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   661
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   662
    BOOL showingMaster = [self isShowingMaster];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   663
    if (showingMaster) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   664
        if (_cornerViews) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   665
            for (UIView *corner in _cornerViews) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   666
                corner.hidden = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   667
            }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   668
            _dividerView.hidden = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   669
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   670
        [UIView beginAnimations:MG_ANIMATION_CHANGE_SUBVIEWS_ORDER context:nil];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   671
        [UIView setAnimationDelegate:self];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   672
        [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   673
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   674
    self.masterBeforeDetail = (!self.masterBeforeDetail);
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   675
    if (showingMaster) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   676
        [UIView commitAnimations];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   677
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   678
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   679
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   680
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   681
- (IBAction)toggleMasterView:(id)sender
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   682
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   683
    if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   684
        [_hiddenPopoverController dismissPopoverAnimated:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   685
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   686
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   687
    if (![self isShowingMaster]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   688
        // We're about to show the master view. Ensure it's in place off-screen to be animated in.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   689
        _reconfigurePopup = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   690
        [self reconfigureForMasterInPopover:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   691
        [self layoutSubviews];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   692
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   693
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   694
    // This action functions on the current primary orientation; it is independent of the other primary orientation.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   695
    [UIView beginAnimations:@"toggleMaster" context:nil];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   696
    if (self.isLandscape) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   697
        self.showsMasterInLandscape = !_showsMasterInLandscape;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   698
    } else {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   699
        self.showsMasterInPortrait = !_showsMasterInPortrait;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   700
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   701
    [UIView commitAnimations];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   702
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   703
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   704
6908
896ed2afcfb8 ios: turn on more warning messages and start correcting them
koda
parents: 6659
diff changeset
   705
- (IBAction)showMasterPopover:(id) sender
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   706
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   707
    if (_hiddenPopoverController && !(_hiddenPopoverController.popoverVisible)) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   708
        // Inform delegate.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   709
        if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:popoverController:willPresentViewController:)]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   710
            [(NSObject <MGSplitViewControllerDelegate> *)_delegate splitViewController:self
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   711
                                                                     popoverController:_hiddenPopoverController
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   712
                                                             willPresentViewController:self.masterViewController];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   713
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   714
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   715
        // Show popover.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   716
        [_hiddenPopoverController presentPopoverFromBarButtonItem:_barButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   717
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   718
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   719
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   720
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   721
#pragma mark -
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   722
#pragma mark Accessors and properties
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   723
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   724
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   725
- (id)delegate
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   726
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   727
    return _delegate;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   728
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   729
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   730
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   731
- (void)setDelegate:(id <MGSplitViewControllerDelegate>)newDelegate
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   732
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   733
    if (newDelegate != _delegate &&
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   734
        (!newDelegate || [(NSObject *)newDelegate conformsToProtocol:@protocol(MGSplitViewControllerDelegate)])) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   735
        _delegate = newDelegate;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   736
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   737
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   738
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   739
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   740
- (BOOL)showsMasterInPortrait
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   741
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   742
    return _showsMasterInPortrait;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   743
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   744
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   745
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   746
- (void)setShowsMasterInPortrait:(BOOL)flag
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   747
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   748
    if (flag != _showsMasterInPortrait) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   749
        _showsMasterInPortrait = flag;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   750
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   751
        if (![self isLandscape]) { // i.e. if this will cause a visual change.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   752
            if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   753
                [_hiddenPopoverController dismissPopoverAnimated:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   754
            }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   755
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   756
            // Rearrange views.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   757
            _reconfigurePopup = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   758
            [self layoutSubviews];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   759
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   760
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   761
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   762
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   763
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   764
- (BOOL)showsMasterInLandscape
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   765
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   766
    return _showsMasterInLandscape;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   767
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   768
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   769
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   770
- (void)setShowsMasterInLandscape:(BOOL)flag
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   771
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   772
    if (flag != _showsMasterInLandscape) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   773
        _showsMasterInLandscape = flag;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   774
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   775
        if ([self isLandscape]) { // i.e. if this will cause a visual change.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   776
            if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   777
                [_hiddenPopoverController dismissPopoverAnimated:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   778
            }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   779
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   780
            // Rearrange views.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   781
            _reconfigurePopup = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   782
            [self layoutSubviews];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   783
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   784
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   785
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   786
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   787
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   788
- (BOOL)isVertical
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   789
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   790
    return _vertical;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   791
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   792
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   793
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   794
- (void)setVertical:(BOOL)flag
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   795
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   796
    if (flag != _vertical) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   797
        if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   798
            [_hiddenPopoverController dismissPopoverAnimated:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   799
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   800
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   801
        _vertical = flag;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   802
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   803
        // Inform delegate.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   804
        if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:willChangeSplitOrientationToVertical:)]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   805
            [_delegate splitViewController:self willChangeSplitOrientationToVertical:_vertical];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   806
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   807
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   808
        [self layoutSubviews];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   809
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   810
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   811
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   812
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   813
- (BOOL)isMasterBeforeDetail
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   814
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   815
    return _masterBeforeDetail;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   816
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   817
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   818
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   819
- (void)setMasterBeforeDetail:(BOOL)flag
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   820
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   821
    if (flag != _masterBeforeDetail) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   822
        if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   823
            [_hiddenPopoverController dismissPopoverAnimated:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   824
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   825
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   826
        _masterBeforeDetail = flag;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   827
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   828
        if ([self isShowingMaster]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   829
            [self layoutSubviews];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   830
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   831
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   832
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   833
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   834
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   835
- (float)splitPosition
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   836
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   837
    return _splitPosition;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   838
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   839
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   840
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   841
- (void)setSplitPosition:(float)posn
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   842
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   843
    // Check to see if delegate wishes to constrain the position.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   844
    float newPosn = posn;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   845
    BOOL constrained = NO;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   846
    CGSize fullSize = [self splitViewSizeForOrientation:self.interfaceOrientation];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   847
    if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:constrainSplitPosition:splitViewSize:)]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   848
        newPosn = [_delegate splitViewController:self constrainSplitPosition:newPosn splitViewSize:fullSize];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   849
        constrained = YES; // implicitly trust delegate's response.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   850
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   851
    } else {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   852
        // Apply default constraints if delegate doesn't wish to participate.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   853
        float minPos = MG_MIN_VIEW_WIDTH;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   854
        float maxPos = ((_vertical) ? fullSize.width : fullSize.height) - (MG_MIN_VIEW_WIDTH + _splitWidth);
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   855
        constrained = (newPosn != _splitPosition && newPosn >= minPos && newPosn <= maxPos);
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   856
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   857
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   858
    if (constrained) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   859
        if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   860
            [_hiddenPopoverController dismissPopoverAnimated:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   861
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   862
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   863
        _splitPosition = newPosn;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   864
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   865
        // Inform delegate.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   866
        if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:willMoveSplitToPosition:)]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   867
            [_delegate splitViewController:self willMoveSplitToPosition:_splitPosition];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   868
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   869
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   870
        if ([self isShowingMaster]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   871
            [self layoutSubviews];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   872
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   873
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   874
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   875
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   876
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   877
- (void)setSplitPosition:(float)posn animated:(BOOL)animate
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   878
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   879
    BOOL shouldAnimate = (animate && [self isShowingMaster]);
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   880
    if (shouldAnimate) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   881
        [UIView beginAnimations:@"SplitPosition" context:nil];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   882
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   883
    [self setSplitPosition:posn];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   884
    if (shouldAnimate) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   885
        [UIView commitAnimations];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   886
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   887
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   888
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   889
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   890
- (float)splitWidth
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   891
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   892
    return _splitWidth;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   893
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   894
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   895
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   896
- (void)setSplitWidth:(float)width
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   897
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   898
    if (width != _splitWidth && width >= 0) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   899
        _splitWidth = width;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   900
        if ([self isShowingMaster]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   901
            [self layoutSubviews];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   902
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   903
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   904
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   905
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   906
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   907
- (NSArray *)viewControllers
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   908
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   909
    return [[_viewControllers copy] autorelease];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   910
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   911
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   912
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   913
- (void)setViewControllers:(NSArray *)controllers
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   914
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   915
    if (controllers != _viewControllers) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   916
        for (UIViewController *controller in _viewControllers) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   917
            if ([controller isKindOfClass:[UIViewController class]]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   918
                [controller.view removeFromSuperview];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   919
            }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   920
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   921
        [_viewControllers release];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   922
        _viewControllers = [[NSMutableArray alloc] initWithCapacity:2];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   923
        if (controllers && [controllers count] >= 2) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   924
            self.masterViewController = [controllers objectAtIndex:0];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   925
            self.detailViewController = [controllers objectAtIndex:1];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   926
        } else {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   927
            NSLog(@"Error: %@ requires 2 view-controllers. (%@)", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   928
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   929
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   930
        [self layoutSubviews];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   931
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   932
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   933
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   934
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   935
- (UIViewController *)masterViewController
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   936
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   937
    if (_viewControllers && [_viewControllers count] > 0) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   938
        NSObject *controller = [_viewControllers objectAtIndex:0];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   939
        if ([controller isKindOfClass:[UIViewController class]]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   940
            return [[controller retain] autorelease];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   941
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   942
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   943
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   944
    return nil;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   945
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   946
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   947
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   948
- (void)setMasterViewController:(UIViewController *)master
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   949
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   950
    if (!_viewControllers) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   951
        _viewControllers = [[NSMutableArray alloc] initWithCapacity:2];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   952
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   953
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   954
    NSObject *newMaster = master;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   955
    if (!newMaster) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   956
        newMaster = [NSNull null];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   957
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   958
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   959
    BOOL changed = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   960
    if ([_viewControllers count] > 0) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   961
        if ([_viewControllers objectAtIndex:0] == newMaster) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   962
            changed = NO;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   963
        } else {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   964
            [_viewControllers replaceObjectAtIndex:0 withObject:newMaster];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   965
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   966
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   967
    } else {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   968
        [_viewControllers addObject:newMaster];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   969
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   970
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   971
    if (changed) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   972
        [self layoutSubviews];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   973
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   974
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   975
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   976
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   977
- (UIViewController *)detailViewController
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   978
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   979
    if (_viewControllers && [_viewControllers count] > 1) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   980
        NSObject *controller = [_viewControllers objectAtIndex:1];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   981
        if ([controller isKindOfClass:[UIViewController class]]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   982
            return [[controller retain] autorelease];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   983
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   984
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   985
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   986
    return nil;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   987
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   988
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   989
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   990
- (void)setDetailViewController:(UIViewController *)detail
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
   991
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   992
    if (!_viewControllers) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   993
        _viewControllers = [[NSMutableArray alloc] initWithCapacity:2];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   994
        [_viewControllers addObject:[NSNull null]];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   995
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   996
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   997
    BOOL changed = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   998
    if ([_viewControllers count] > 1) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   999
        if ([_viewControllers objectAtIndex:1] == detail) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1000
            changed = NO;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1001
        } else {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1002
            [_viewControllers replaceObjectAtIndex:1 withObject:detail];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1003
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1004
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1005
    } else {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1006
        [_viewControllers addObject:detail];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1007
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1008
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1009
    if (changed) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1010
        [self layoutSubviews];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1011
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1012
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1013
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1014
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1015
- (MGSplitDividerView *)dividerView
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1016
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1017
    return [[_dividerView retain] autorelease];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1018
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1019
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1020
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1021
- (void)setDividerView:(MGSplitDividerView *)divider
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1022
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1023
    if (divider != _dividerView) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1024
        [_dividerView removeFromSuperview];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1025
        [_dividerView release];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1026
        _dividerView = [divider retain];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1027
        _dividerView.splitViewController = self;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1028
        _dividerView.backgroundColor = MG_DEFAULT_CORNER_COLOR;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1029
        if ([self isShowingMaster]) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1030
            [self layoutSubviews];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1031
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1032
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1033
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1034
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1035
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1036
- (BOOL)allowsDraggingDivider
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1037
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1038
    if (_dividerView) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1039
        return _dividerView.allowsDragging;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1040
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1041
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1042
    return NO;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1043
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1044
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1045
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1046
- (void)setAllowsDraggingDivider:(BOOL)flag
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1047
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1048
    if (self.allowsDraggingDivider != flag && _dividerView) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1049
        _dividerView.allowsDragging = flag;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1050
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1051
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1052
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1053
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1054
- (MGSplitViewDividerStyle)dividerStyle
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1055
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1056
    return _dividerStyle;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1057
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1058
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1059
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1060
- (void)setDividerStyle:(MGSplitViewDividerStyle)newStyle
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1061
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1062
    if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1063
        [_hiddenPopoverController dismissPopoverAnimated:NO];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1064
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1065
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1066
    // We don't check to see if newStyle equals _dividerStyle, because it's a meta-setting.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1067
    // Aspects could have been changed since it was set.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1068
    _dividerStyle = newStyle;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1069
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1070
    // Reconfigure general appearance and behaviour.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1071
    float cornerRadius;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1072
    if (_dividerStyle == MGSplitViewDividerStyleThin) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1073
        cornerRadius = MG_DEFAULT_CORNER_RADIUS;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1074
        _splitWidth = MG_DEFAULT_SPLIT_WIDTH;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1075
        self.allowsDraggingDivider = NO;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1076
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1077
    } else if (_dividerStyle == MGSplitViewDividerStylePaneSplitter) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1078
        cornerRadius = MG_PANESPLITTER_CORNER_RADIUS;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1079
        _splitWidth = MG_PANESPLITTER_SPLIT_WIDTH;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1080
        self.allowsDraggingDivider = YES;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1081
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1082
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1083
    // Update divider and corners.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1084
    [_dividerView setNeedsDisplay];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1085
    if (_cornerViews) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1086
        for (MGSplitCornersView *corner in _cornerViews) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1087
            corner.cornerRadius = cornerRadius;
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1088
        }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1089
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1090
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1091
    // Layout all views.
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1092
    [self layoutSubviews];
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1093
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1094
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1095
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1096
- (void)setDividerStyle:(MGSplitViewDividerStyle)newStyle animated:(BOOL)animate
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1097
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1098
    BOOL shouldAnimate = (animate && [self isShowingMaster]);
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1099
    if (shouldAnimate) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1100
        [UIView beginAnimations:@"DividerStyle" context:nil];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1101
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1102
    [self setDividerStyle:newStyle];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1103
    if (shouldAnimate) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1104
        [UIView commitAnimations];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1105
    }
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1106
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1107
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1108
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1109
- (NSArray *)cornerViews
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1110
{
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1111
    if (_cornerViews) {
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1112
        return [[_cornerViews retain] autorelease];
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1113
    }
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1114
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
  1115
    return nil;
6658
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1116
}
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1117
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1118
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1119
@synthesize showsMasterInPortrait;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1120
@synthesize showsMasterInLandscape;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1121
@synthesize vertical;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1122
@synthesize delegate;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1123
@synthesize viewControllers;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1124
@synthesize masterViewController;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1125
@synthesize detailViewController;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1126
@synthesize dividerView;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1127
@synthesize splitPosition;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1128
@synthesize splitWidth;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1129
@synthesize allowsDraggingDivider;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1130
@synthesize dividerStyle;
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1131
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1132
2cccf6b2b89d added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
diff changeset
  1133
@end