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