Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mbaltaks/MGSplitViewController
base: bc09490ba3
...
head fork: mbaltaks/MGSplitViewController
compare: d22a5a931b
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
10 Classes/MGSplitCornersView.h
@@ -8,6 +8,8 @@
#import <UIKit/UIKit.h>
+int floatsAreEqual(float a, float b);
+
typedef enum _MGCornersPosition {
MGCornersPositionLeadingVertical = 0, // top of screen for a left/right split.
MGCornersPositionTrailingVertical = 1, // bottom of screen for a left/right split.
@@ -17,10 +19,10 @@ typedef enum _MGCornersPosition {
@class MGSplitViewController;
@interface MGSplitCornersView : UIView {
- float cornerRadius;
- MGSplitViewController *splitViewController;
- MGCornersPosition cornersPosition;
- UIColor *cornerBackgroundColor;
+ float cornerRadius_;
+ MGSplitViewController *splitViewController_;
+ MGCornersPosition cornersPosition_;
+ UIColor *cornerBackgroundColor_;
}
@property (nonatomic, assign) float cornerRadius;
View
28 Classes/MGSplitCornersView.m
@@ -33,16 +33,14 @@ - (id)initWithFrame:(CGRect)frame
- (void)dealloc
{
- self.cornerBackgroundColor = nil;
-
- [super dealloc];
+ cornerBackgroundColor_ = nil;
}
#pragma mark -
#pragma mark Geometry helpers
-
+double deg2Rad(double degrees);
double deg2Rad(double degrees)
{
// Converts degrees to radians.
@@ -50,12 +48,24 @@ - (void)dealloc
}
+double rad2Deg(double radians);
double rad2Deg(double radians)
{
// Converts radians to degrees.
return radians * (180 / M_PI);
}
+int floatsAreEqual(float a, float b)
+{
+ int r = 1;
+ if (a - b > 0
+ || a - b < 0)
+ {
+ r = 0;
+ }
+ return r;
+}
+
#pragma mark -
#pragma mark Drawing
@@ -197,8 +207,9 @@ - (void)drawRect:(CGRect)rect
- (void)setCornerRadius:(float)newRadius
{
- if (newRadius != cornerRadius) {
- cornerRadius = newRadius;
+ if (!floatsAreEqual(newRadius, cornerRadius_))
+ {
+ cornerRadius_ = newRadius;
[self setNeedsDisplay];
}
}
@@ -224,9 +235,8 @@ - (void)setCornersPosition:(MGCornersPosition)posn
- (void)setCornerBackgroundColor:(UIColor *)color
{
- if (color != cornerBackgroundColor) {
- [cornerBackgroundColor release];
- cornerBackgroundColor = [color retain];
+ if (color != cornerBackgroundColor_) {
+ cornerBackgroundColor_ = color;
[self setNeedsDisplay];
}
}
View
4 Classes/MGSplitDividerView.h
@@ -10,8 +10,8 @@
@class MGSplitViewController;
@interface MGSplitDividerView : UIView {
- MGSplitViewController *splitViewController;
- BOOL allowsDragging;
+ MGSplitViewController *splitViewController_;
+ BOOL allowsDragging_;
}
@property (nonatomic, assign) MGSplitViewController *splitViewController; // weak ref.
View
3  Classes/MGSplitDividerView.m
@@ -30,8 +30,7 @@ - (id)initWithFrame:(CGRect)frame
- (void)dealloc
{
- self.splitViewController = nil;
- [super dealloc];
+ splitViewController_ = nil;
}
View
37 Classes/MGSplitViewController.m
@@ -24,7 +24,7 @@
#define MG_ANIMATION_CHANGE_SUBVIEWS_ORDER @"ChangeSubviewsOrder" // Animation ID for internal use.
-@interface MGSplitViewController (MGPrivateMethods)
+@interface MGSplitViewController ()
- (void)setup;
- (CGSize)splitViewSizeForOrientation:(UIInterfaceOrientation)theOrientation;
@@ -149,13 +149,6 @@ - (void)dealloc
{
_delegate = nil;
[self.view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
- [_viewControllers release];
- [_barButtonItem release];
- [_hiddenPopoverController release];
- [_dividerView release];
- [_cornerViews release];
-
- [super dealloc];
}
@@ -437,9 +430,7 @@ - (void)layoutSubviewsForInterfaceOrientation:(UIInterfaceOrientation)theOrienta
trailingCorners.cornerBackgroundColor = MG_DEFAULT_CORNER_COLOR;
trailingCorners.cornerRadius = MG_DEFAULT_CORNER_RADIUS;
_cornerViews = [[NSArray alloc] initWithObjects:leadingCorners, trailingCorners, nil];
- [leadingCorners release];
- [trailingCorners release];
-
+
} else if ([_cornerViews count] == 2) {
leadingCorners = [_cornerViews objectAtIndex:0];
trailingCorners = [_cornerViews objectAtIndex:1];
@@ -559,7 +550,6 @@ - (void)reconfigureForMasterInPopover:(BOOL)inPopover
if (inPopover && !_hiddenPopoverController && !_barButtonItem) {
// Create and configure popover for our masterViewController.
- [_hiddenPopoverController release];
_hiddenPopoverController = nil;
[self.masterViewController viewWillDisappear:NO];
_hiddenPopoverController = [[UIPopoverController alloc] initWithContentViewController:self.masterViewController];
@@ -585,7 +575,6 @@ - (void)reconfigureForMasterInPopover:(BOOL)inPopover
// Remove master from popover and destroy popover, if it exists.
[_hiddenPopoverController dismissPopoverAnimated:NO];
- [_hiddenPopoverController release];
_hiddenPopoverController = nil;
// Inform delegate that the _barButtonItem will become invalid.
@@ -596,7 +585,6 @@ - (void)reconfigureForMasterInPopover:(BOOL)inPopover
}
// Destroy _barButtonItem.
- [_barButtonItem release];
_barButtonItem = nil;
// Move master view.
@@ -857,7 +845,7 @@ - (void)setSplitPosition:(float)posn
// Apply default constraints if delegate doesn't wish to participate.
float minPos = MG_MIN_VIEW_WIDTH;
float maxPos = ((_vertical) ? fullSize.width : fullSize.height) - (MG_MIN_VIEW_WIDTH + _splitWidth);
- constrained = (newPosn != _splitPosition && newPosn >= minPos && newPosn <= maxPos);
+ constrained = (!floatsAreEqual(newPosn, _splitPosition) && newPosn >= minPos && newPosn <= maxPos);
}
if (constrained) {
@@ -900,7 +888,7 @@ - (float)splitWidth
- (void)setSplitWidth:(float)width
{
- if (width != _splitWidth && width >= 0) {
+ if (!floatsAreEqual(width, _splitWidth) && width >= 0) {
_splitWidth = width;
if ([self isShowingMaster]) {
[self layoutSubviews];
@@ -911,7 +899,7 @@ - (void)setSplitWidth:(float)width
- (NSArray *)viewControllers
{
- return [[_viewControllers copy] autorelease];
+ return [_viewControllers copy];
}
@@ -923,7 +911,6 @@ - (void)setViewControllers:(NSArray *)controllers
[controller.view removeFromSuperview];
}
}
- [_viewControllers release];
_viewControllers = [[NSMutableArray alloc] initWithCapacity:2];
if (controllers && [controllers count] >= 2) {
self.masterViewController = [controllers objectAtIndex:0];
@@ -942,7 +929,7 @@ - (UIViewController *)masterViewController
if (_viewControllers && [_viewControllers count] > 0) {
NSObject *controller = [_viewControllers objectAtIndex:0];
if ([controller isKindOfClass:[UIViewController class]]) {
- return [[controller retain] autorelease];
+ return (UIViewController *)controller;
}
}
@@ -984,7 +971,7 @@ - (UIViewController *)detailViewController
if (_viewControllers && [_viewControllers count] > 1) {
NSObject *controller = [_viewControllers objectAtIndex:1];
if ([controller isKindOfClass:[UIViewController class]]) {
- return [[controller retain] autorelease];
+ return (UIViewController *)controller;
}
}
@@ -1020,7 +1007,7 @@ - (void)setDetailViewController:(UIViewController *)detail
- (MGSplitDividerView *)dividerView
{
- return [[_dividerView retain] autorelease];
+ return _dividerView;
}
@@ -1028,8 +1015,7 @@ - (void)setDividerView:(MGSplitDividerView *)divider
{
if (divider != _dividerView) {
[_dividerView removeFromSuperview];
- [_dividerView release];
- _dividerView = [divider retain];
+ _dividerView = divider;
_dividerView.splitViewController = self;
_dividerView.backgroundColor = MG_DEFAULT_CORNER_COLOR;
if ([self isShowingMaster]) {
@@ -1074,9 +1060,8 @@ - (void)setDividerStyle:(MGSplitViewDividerStyle)newStyle
_dividerStyle = newStyle;
// Reconfigure general appearance and behaviour.
- float cornerRadius;
+ float cornerRadius = MG_DEFAULT_CORNER_RADIUS;
if (_dividerStyle == MGSplitViewDividerStyleThin) {
- cornerRadius = MG_DEFAULT_CORNER_RADIUS;
_splitWidth = MG_DEFAULT_SPLIT_WIDTH;
self.allowsDraggingDivider = NO;
@@ -1115,7 +1100,7 @@ - (void)setDividerStyle:(MGSplitViewDividerStyle)newStyle animated:(BOOL)animate
- (NSArray *)cornerViews
{
if (_cornerViews) {
- return [[_cornerViews retain] autorelease];
+ return _cornerViews;
}
return nil;

No commit comments for this range

Something went wrong with that request. Please try again.