forked from mattgemmell/MGSplitViewController
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c0be04c
Showing
21 changed files
with
4,083 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// DetailViewController.h | ||
// MGSplitView | ||
// | ||
// Created by Matt Gemmell on 26/07/2010. | ||
// Copyright Instinctive Code 2010. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "MGSplitViewController.h" | ||
|
||
@interface DetailViewController : UIViewController <UIPopoverControllerDelegate, MGSplitViewControllerDelegate> { | ||
IBOutlet MGSplitViewController *splitController; | ||
IBOutlet UIBarButtonItem *toggleItem; | ||
IBOutlet UIBarButtonItem *verticalItem; | ||
IBOutlet UIBarButtonItem *dividerStyleItem; | ||
UIPopoverController *popoverController; | ||
UIToolbar *toolbar; | ||
|
||
id detailItem; | ||
UILabel *detailDescriptionLabel; | ||
} | ||
|
||
@property (nonatomic, retain) IBOutlet UIToolbar *toolbar; | ||
@property (nonatomic, retain) id detailItem; | ||
@property (nonatomic, retain) IBOutlet UILabel *detailDescriptionLabel; | ||
|
||
- (IBAction)toggleMasterView:(id)sender; | ||
- (IBAction)toggleVertical:(id)sender; | ||
- (IBAction)toggleDividerStyle:(id)sender; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
// | ||
// DetailViewController.m | ||
// MGSplitView | ||
// | ||
// Created by Matt Gemmell on 26/07/2010. | ||
// Copyright Instinctive Code 2010. | ||
// | ||
|
||
#import "DetailViewController.h" | ||
#import "RootViewController.h" | ||
|
||
|
||
@interface DetailViewController () | ||
|
||
@property (nonatomic, retain) UIPopoverController *popoverController; | ||
- (void)configureView; | ||
|
||
@end | ||
|
||
|
||
@implementation DetailViewController | ||
|
||
|
||
@synthesize toolbar, popoverController, detailItem, detailDescriptionLabel; | ||
|
||
|
||
#pragma mark - | ||
#pragma mark Managing the detail item | ||
|
||
|
||
// When setting the detail item, update the view and dismiss the popover controller if it's showing. | ||
- (void)setDetailItem:(id)newDetailItem | ||
{ | ||
if (detailItem != newDetailItem) { | ||
[detailItem release]; | ||
detailItem = [newDetailItem retain]; | ||
|
||
// Update the view. | ||
[self configureView]; | ||
} | ||
|
||
if (popoverController != nil) { | ||
[popoverController dismissPopoverAnimated:YES]; | ||
} | ||
} | ||
|
||
|
||
- (void)configureView | ||
{ | ||
// Update the user interface for the detail item. | ||
detailDescriptionLabel.text = [detailItem description]; | ||
toggleItem.title = ([splitController isShowingMaster]) ? @"Hide Master" : @"Show Master"; // "I... AM... THE MASTER!" Derek Jacobi. Gave me chills. | ||
verticalItem.title = (splitController.vertical) ? @"Horizontal Split" : @"Vertical Split"; | ||
dividerStyleItem.title = (splitController.dividerStyle == MGSplitViewDividerStyleThin) ? @"Enable Dragging" : @"Disable Dragging"; | ||
} | ||
|
||
|
||
#pragma mark - | ||
#pragma mark Split view support | ||
|
||
|
||
- (void)splitViewController:(MGSplitViewController*)svc | ||
willHideViewController:(UIViewController *)aViewController | ||
withBarButtonItem:(UIBarButtonItem*)barButtonItem | ||
forPopoverController: (UIPopoverController*)pc | ||
{ | ||
//NSLog(@"%@", NSStringFromSelector(_cmd)); | ||
|
||
if (barButtonItem) { | ||
barButtonItem.title = @"Popover"; | ||
NSMutableArray *items = [[toolbar items] mutableCopy]; | ||
[items insertObject:barButtonItem atIndex:0]; | ||
[toolbar setItems:items animated:YES]; | ||
[items release]; | ||
} | ||
self.popoverController = pc; | ||
} | ||
|
||
|
||
// Called when the view is shown again in the split view, invalidating the button and popover controller. | ||
- (void)splitViewController:(MGSplitViewController*)svc | ||
willShowViewController:(UIViewController *)aViewController | ||
invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem | ||
{ | ||
//NSLog(@"%@", NSStringFromSelector(_cmd)); | ||
|
||
if (barButtonItem) { | ||
NSMutableArray *items = [[toolbar items] mutableCopy]; | ||
[items removeObject:barButtonItem]; | ||
[toolbar setItems:items animated:YES]; | ||
[items release]; | ||
} | ||
self.popoverController = nil; | ||
} | ||
|
||
|
||
- (void)splitViewController:(MGSplitViewController*)svc | ||
popoverController:(UIPopoverController*)pc | ||
willPresentViewController:(UIViewController *)aViewController | ||
{ | ||
//NSLog(@"%@", NSStringFromSelector(_cmd)); | ||
} | ||
|
||
|
||
- (void)splitViewController:(MGSplitViewController*)svc willChangeSplitOrientationToVertical:(BOOL)isVertical | ||
{ | ||
//NSLog(@"%@", NSStringFromSelector(_cmd)); | ||
} | ||
|
||
|
||
- (void)splitViewController:(MGSplitViewController*)svc willMoveSplitToPosition:(float)position | ||
{ | ||
//NSLog(@"%@", NSStringFromSelector(_cmd)); | ||
} | ||
|
||
|
||
- (float)splitViewController:(MGSplitViewController *)svc constrainSplitPosition:(float)proposedPosition splitViewSize:(CGSize)viewSize | ||
{ | ||
//NSLog(@"%@", NSStringFromSelector(_cmd)); | ||
return proposedPosition; | ||
} | ||
|
||
|
||
#pragma mark - | ||
#pragma mark Actions | ||
|
||
|
||
- (IBAction)toggleMasterView:(id)sender | ||
{ | ||
[splitController toggleMasterView:sender]; | ||
[self configureView]; | ||
} | ||
|
||
|
||
- (IBAction)toggleVertical:(id)sender | ||
{ | ||
[splitController toggleSplitOrientation:self]; | ||
[self configureView]; | ||
} | ||
|
||
|
||
- (IBAction)toggleDividerStyle:(id)sender | ||
{ | ||
MGSplitViewDividerStyle newStyle = ((splitController.dividerStyle == MGSplitViewDividerStyleThin) ? MGSplitViewDividerStylePaneSplitter : MGSplitViewDividerStyleThin); | ||
[splitController setDividerStyle:newStyle animated:YES]; | ||
[self configureView]; | ||
} | ||
|
||
|
||
#pragma mark - | ||
#pragma mark Rotation support | ||
|
||
|
||
// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape. | ||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation | ||
{ | ||
return YES; | ||
} | ||
|
||
|
||
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation | ||
{ | ||
[self configureView]; | ||
} | ||
|
||
|
||
- (void)dealloc | ||
{ | ||
[popoverController release]; | ||
[toolbar release]; | ||
|
||
[detailItem release]; | ||
[detailDescriptionLabel release]; | ||
[super dealloc]; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// MGSplitCornersView.h | ||
// MGSplitView | ||
// | ||
// Created by Matt Gemmell on 28/07/2010. | ||
// Copyright 2010 Instinctive Code. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
typedef enum _MGCornersPosition { | ||
MGCornersPositionLeadingVertical = 0, // top of screen for a left/right split. | ||
MGCornersPositionTrailingVertical = 1, // bottom of screen for a left/right split. | ||
MGCornersPositionLeadingHorizontal = 2, // left of screen for a top/bottom split. | ||
MGCornersPositionTrailingHorizontal = 3 // right of screen for a top/bottom split. | ||
} MGCornersPosition; | ||
|
||
@class MGSplitViewController; | ||
@interface MGSplitCornersView : UIView { | ||
float cornerRadius; | ||
MGSplitViewController *splitViewController; | ||
MGCornersPosition cornersPosition; | ||
UIColor *cornerBackgroundColor; | ||
} | ||
|
||
@property (nonatomic, assign) float cornerRadius; | ||
@property (nonatomic, assign) MGSplitViewController *splitViewController; // weak ref. | ||
@property (nonatomic, assign) MGCornersPosition cornersPosition; // don't change this manually; let the splitViewController manage it. | ||
@property (nonatomic, retain) UIColor *cornerBackgroundColor; | ||
|
||
@end |
Oops, something went wrong.