Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

REnamed WrapController to IIWrapController.

Fixed some stuff too.
  • Loading branch information...
commit c82e683bc29bb3415a548fedea4ae6a6cf8fc448 1 parent 4119b27
@Inferis authored
View
2  ViewDeck/IIViewDeckController.m
@@ -86,7 +86,7 @@
#import <objc/runtime.h>
#import <QuartzCore/QuartzCore.h>
#import <objc/message.h>
-#import "WrapController.h"
+#import "IIWrapController.h"
#define DURATION_FAST 0.3
#define DURATION_SLOW 0.3
View
14 ViewDeck/WrapController.h → ViewDeck/IIWrapController.h
@@ -25,14 +25,14 @@
#import <UIKit/UIKit.h>
-@interface WrapController : UIViewController
+@interface IIWrapController : UIViewController
@property (nonatomic, readonly, retain) UIViewController* wrappedController;
-@property (nonatomic, copy) void(^onViewDidLoad)(WrapController* controller);
-@property (nonatomic, copy) void(^onViewWillAppear)(WrapController* controller, BOOL animated);
-@property (nonatomic, copy) void(^onViewDidAppear)(WrapController* controller, BOOL animated);
-@property (nonatomic, copy) void(^onViewWillDisappear)(WrapController* controller, BOOL animated);
-@property (nonatomic, copy) void(^onViewDidDisappear)(WrapController* controller, BOOL animated);
+@property (nonatomic, copy) void(^onViewDidLoad)(IIWrapController* controller);
+@property (nonatomic, copy) void(^onViewWillAppear)(IIWrapController* controller, BOOL animated);
+@property (nonatomic, copy) void(^onViewDidAppear)(IIWrapController* controller, BOOL animated);
+@property (nonatomic, copy) void(^onViewWillDisappear)(IIWrapController* controller, BOOL animated);
+@property (nonatomic, copy) void(^onViewDidDisappear)(IIWrapController* controller, BOOL animated);
- (id)initWithViewController:(UIViewController*)controller;
@@ -42,6 +42,6 @@
// contained viewcontrollers, a la UINavigationController.
@interface UIViewController (WrapControllerItem)
-@property(nonatomic,readonly,assign) WrapController *wrapController;
+@property(nonatomic,readonly,assign) IIWrapController *wrapController;
@end
View
53 ViewDeck/WrapController.m → ViewDeck/IIWrapController.m
@@ -42,18 +42,18 @@
#define II_CGRectOffsetBottomAndShrink(rect, offset) ({__typeof__(rect) __r = (rect); __typeof__(offset) __o = (offset); (CGRect) { __r.origin.x, __r.origin.y, __r.size.width, __r.size.height-__o }; })
#define II_CGRectShrink(rect, w, h) ({__typeof__(rect) __r = (rect); __typeof__(w) __w = (w); __typeof__(h) __h = (h); (CGRect) { __r.origin, __r.size.width - __w, __r.size.height - __h }; })
-#import "WrapController.h"
+#import "IIWrapController.h"
#import <objc/runtime.h>
#import <objc/message.h>
@interface UIViewController (WrappedItem_Internal)
// internal setter for the wrapController property on UIViewController
-- (void)setWrapController:(WrapController *)wrapController;
+- (void)setWrapController:(IIWrapController*)wrapController;
@end
-@implementation WrapController
+@implementation IIWrapController
@synthesize wrappedController = _wrappedController;
@synthesize onViewDidLoad = _onViewDidLoad;
@@ -75,15 +75,11 @@ - (id)initWithViewController:(UIViewController *)controller {
}
- (CGFloat)statusBarHeight {
-// if (![[self.referenceView superview] isKindOfClass:[UIWindow class]])
-// return 0;
-//
return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)
? [UIApplication sharedApplication].statusBarFrame.size.width
: [UIApplication sharedApplication].statusBarFrame.size.height;
}
-// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
#if __IPHONE_5_0
@@ -91,11 +87,15 @@ - (void)loadView
[self addChildViewController:self.wrappedController];
#endif
- self.view = II_AUTORELEASE([[UIView alloc] initWithFrame:II_CGRectOffsetTopAndShrink(self.wrappedController.view.frame, [self statusBarHeight])]);
- self.view.autoresizingMask = self.wrappedController.view.autoresizingMask;
- self.wrappedController.view.frame = self.view.bounds;
- self.wrappedController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ self.view = II_AUTORELEASE([[UIView alloc] initWithFrame:II_CGRectOffsetTopAndShrink(_wrappedController.view.frame, [self statusBarHeight])]);
+ self.view.autoresizingMask = _wrappedController.view.autoresizingMask;
+ _wrappedController.view.frame = self.view.bounds;
+ _wrappedController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.wrappedController.view];
+#if __IPHONE_5_0
+ if ([_wrappedController respondsToSelector:@selector(didMoveToParentViewController:)])
+ [_wrappedController didMoveToParentViewController:self];
+#endif
}
- (void)viewDidLoad {
@@ -113,13 +113,20 @@ - (void)viewDidUnload
- (void)dealloc {
#if __IPHONE_5_0
- if ([_wrappedController respondsToSelector:@selector(removeFromParentViewController)]) {
+ if ([_wrappedController respondsToSelector:@selector(willMoveToParentViewController:)])
+ [_wrappedController willMoveToParentViewController:nil];
+ if ([_wrappedController respondsToSelector:@selector(removeFromParentViewController)])
[_wrappedController removeFromParentViewController];
- }
#endif
[_wrappedController setWrapController:nil];
- II_RELEASE(_wrappedController);
+#if __IPHONE_5_0
+ if ([_wrappedController respondsToSelector:@selector(didMoveToParentViewController:)])
+ [_wrappedController didMoveToParentViewController:nil];
+#endif
+
_wrappedController = nil;
+ II_RELEASE(_wrappedController);
+
#if !II_ARC_ENABLED
[super dealloc];
#endif
@@ -151,7 +158,8 @@ - (void)viewWillAppear:(BOOL)animated
if (self.onViewWillAppear)
self.onViewWillAppear(self, animated);
- [self.wrappedController viewWillAppear:animated];
+ if (![self respondsToSelector:@selector(automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers)])
+ [self.wrappedController viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
@@ -160,7 +168,8 @@ - (void)viewDidAppear:(BOOL)animated
if (self.onViewDidAppear)
self.onViewDidAppear(self, animated);
- [self.wrappedController viewDidAppear:animated];
+ if (![self respondsToSelector:@selector(automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers)])
+ [_wrappedController viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
@@ -169,7 +178,8 @@ - (void)viewWillDisappear:(BOOL)animated
if (self.onViewWillDisappear)
self.onViewWillDisappear(self, animated);
- [self.wrappedController viewWillDisappear:animated];
+ if (![self respondsToSelector:@selector(automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers)])
+ [_wrappedController viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
@@ -178,7 +188,8 @@ - (void)viewDidDisappear:(BOOL)animated
if (self.onViewDidDisappear)
self.onViewDidDisappear(self, animated);
- [self.wrappedController viewDidDisappear:animated];
+ if (![self respondsToSelector:@selector(automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers)])
+ [_wrappedController viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
@@ -223,11 +234,11 @@ @implementation UIViewController (WrapControllerItem)
static const char* wrapControllerKey = "WrapController";
-- (WrapController*)wrapController_core {
+- (IIWrapController*)wrapController_core {
return objc_getAssociatedObject(self, wrapControllerKey);
}
-- (WrapController*)wrapController {
+- (IIWrapController*)wrapController {
id result = [self wrapController_core];
if (!result && self.navigationController)
return [self.navigationController wrapController];
@@ -235,7 +246,7 @@ - (WrapController*)wrapController {
return result;
}
-- (void)setWrapController:(WrapController *)wrapController {
+- (void)setWrapController:(IIWrapController*)wrapController {
objc_setAssociatedObject(self, wrapControllerKey, wrapController, OBJC_ASSOCIATION_ASSIGN);
}
View
12 ViewDeckExample.xcodeproj/project.pbxproj
@@ -21,7 +21,7 @@
E240A9E8148C51AC0077282A /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E240A9E7148C51AC0077282A /* ViewController.xib */; };
E240A9EC148C51E00077282A /* bg.jpg in Resources */ = {isa = PBXBuildFile; fileRef = E240A9EB148C51E00077282A /* bg.jpg */; };
E25F8B3E14B45F2B00C4182C /* IIViewDeckController.m in Sources */ = {isa = PBXBuildFile; fileRef = E25F8B3B14B45F2B00C4182C /* IIViewDeckController.m */; };
- E25F8B3F14B45F2B00C4182C /* WrapController.m in Sources */ = {isa = PBXBuildFile; fileRef = E25F8B3D14B45F2B00C4182C /* WrapController.m */; };
+ E25F8B3F14B45F2B00C4182C /* IIWrapController.m in Sources */ = {isa = PBXBuildFile; fileRef = E25F8B3D14B45F2B00C4182C /* IIWrapController.m */; };
E2955F9814B7D678003DDB4E /* NestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E2955F9614B7D678003DDB4E /* NestViewController.m */; };
E2955F9914B7D678003DDB4E /* NestViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E2955F9714B7D678003DDB4E /* NestViewController.xib */; };
E2B01A28155B385600E05FB9 /* PushedViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E2B01A26155B385600E05FB9 /* PushedViewController.m */; };
@@ -51,8 +51,8 @@
E240A9EB148C51E00077282A /* bg.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = bg.jpg; sourceTree = "<group>"; };
E25F8B3A14B45F2B00C4182C /* IIViewDeckController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IIViewDeckController.h; sourceTree = "<group>"; };
E25F8B3B14B45F2B00C4182C /* IIViewDeckController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IIViewDeckController.m; sourceTree = "<group>"; };
- E25F8B3C14B45F2B00C4182C /* WrapController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WrapController.h; sourceTree = "<group>"; };
- E25F8B3D14B45F2B00C4182C /* WrapController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WrapController.m; sourceTree = "<group>"; };
+ E25F8B3C14B45F2B00C4182C /* IIWrapController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IIWrapController.h; sourceTree = "<group>"; };
+ E25F8B3D14B45F2B00C4182C /* IIWrapController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IIWrapController.m; sourceTree = "<group>"; };
E2955F9514B7D678003DDB4E /* NestViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NestViewController.h; sourceTree = "<group>"; };
E2955F9614B7D678003DDB4E /* NestViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NestViewController.m; sourceTree = "<group>"; };
E2955F9714B7D678003DDB4E /* NestViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NestViewController.xib; sourceTree = "<group>"; };
@@ -161,8 +161,8 @@
children = (
E25F8B3A14B45F2B00C4182C /* IIViewDeckController.h */,
E25F8B3B14B45F2B00C4182C /* IIViewDeckController.m */,
- E25F8B3C14B45F2B00C4182C /* WrapController.h */,
- E25F8B3D14B45F2B00C4182C /* WrapController.m */,
+ E25F8B3C14B45F2B00C4182C /* IIWrapController.h */,
+ E25F8B3D14B45F2B00C4182C /* IIWrapController.m */,
);
path = ViewDeck;
sourceTree = SOURCE_ROOT;
@@ -241,7 +241,7 @@
E240A9D2148ADC020077282A /* LeftViewController.m in Sources */,
E240A9D7148ADC230077282A /* RightViewController.m in Sources */,
E25F8B3E14B45F2B00C4182C /* IIViewDeckController.m in Sources */,
- E25F8B3F14B45F2B00C4182C /* WrapController.m in Sources */,
+ E25F8B3F14B45F2B00C4182C /* IIWrapController.m in Sources */,
E2955F9814B7D678003DDB4E /* NestViewController.m in Sources */,
E2B01A28155B385600E05FB9 /* PushedViewController.m in Sources */,
);
Please sign in to comment.
Something went wrong with that request. Please try again.