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