Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Try subclassing and archiving instead of swizzling.

  • Loading branch information...
commit bce0b4d02201815c0e5f0808b0af358788f0820a 1 parent d2c711d
Sebastian Celis authored March 02, 2012
17  Classes/SCAppDelegate.h
... ...
@@ -1,17 +1,16 @@
1  
-/*
2  
- * Copyright (c) 2010-2010 Sebastian Celis
3  
- * All rights reserved.
4  
- */
  1
+//
  2
+//  SCAppDelegate.h
  3
+//  ExampleNavBarBackground
  4
+//
  5
+//  Created by Sebastian Celis on 6/7/2010.
  6
+//  Copyright 2010-2012 Sebastian Celis. All rights reserved.
  7
+//
5 8
 
6 9
 #import <UIKit/UIKit.h>
7 10
 
8 11
 @interface SCAppDelegate : NSObject <UIApplicationDelegate>
9  
-{
10  
-    UIWindow *window;
11  
-    UINavigationController *navController;
12  
-}
13 12
 
  13
+@property (nonatomic, retain) UINavigationController *navigationController;
14 14
 @property (nonatomic, retain) IBOutlet UIWindow *window;
15  
-@property (nonatomic, retain) UINavigationController *navController;
16 15
 
17 16
 @end
74  Classes/SCAppDelegate.m
... ...
@@ -1,38 +1,78 @@
1  
-/*
2  
- * Copyright (c) 2010-2010 Sebastian Celis
3  
- * All rights reserved.
4  
- */
  1
+//
  2
+//  SCAppDelegate.m
  3
+//  ExampleNavBarBackground
  4
+//
  5
+//  Created by Sebastian Celis on 6/7/2010.
  6
+//  Copyright 2010-2012 Sebastian Celis. All rights reserved.
  7
+//
5 8
 
6 9
 #import "SCAppDelegate.h"
7  
-#import "SCAppUtils.h"
  10
+
  11
+#import "SCNavigationBar.h"
8 12
 #import "SCTestTableViewController.h"
9 13
 
  14
+@interface SCAppDelegate ()
  15
+- (UINavigationController *)customizedNavigationController;
  16
+@end
  17
+
  18
+
10 19
 @implementation SCAppDelegate
11 20
 
12  
-@synthesize window;
13  
-@synthesize navController;
  21
+@synthesize navigationController = _navigationController;
  22
+@synthesize window = _window;
14 23
 
15 24
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
16 25
 {
  26
+    UINavigationController *navigationController = [self customizedNavigationController];
17 27
     SCTestTableViewController *tvc = [[SCTestTableViewController alloc] initWithStyle:UITableViewStylePlain];
18  
-    UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:tvc];
19  
-    [SCAppUtils customizeNavigationController:nc];
20  
-    [self setNavController:nc];
21  
-    
22  
-    [window addSubview:[nc view]];
23  
-    [window makeKeyAndVisible];
24  
-    
  28
+    [navigationController setViewControllers:[NSArray arrayWithObject:tvc]];
  29
+    [self setNavigationController:navigationController];
25 30
     [tvc release];
26  
-    [nc release];
  31
+    
  32
+    [[self window] setRootViewController:navigationController];
  33
+    [[self window] makeKeyAndVisible];
27 34
     
28 35
     return YES;
29 36
 }
30 37
 
31 38
 - (void)dealloc
32 39
 {
33  
-    [navController release];
34  
-    [window release];
  40
+    [_navigationController release];
  41
+    [_window release];
35 42
     [super dealloc];
36 43
 }
37 44
 
  45
+- (UINavigationController *)customizedNavigationController
  46
+{
  47
+    UINavigationController *navController = [[UINavigationController alloc] initWithNibName:nil bundle:nil];
  48
+    
  49
+    // Ensure the UINavigationBar is created so that it can be archived. If we do not access the
  50
+    // navigation bar then it will not be allocated, and thus, it will not be archived by the
  51
+    // NSKeyedArchvier.
  52
+    [navController navigationBar];
  53
+    
  54
+    // Archive the navigation controller.
  55
+    NSMutableData *data = [NSMutableData data];
  56
+    NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
  57
+    [archiver encodeObject:navController forKey:@"root"];
  58
+    [archiver finishEncoding];
  59
+    [archiver release];
  60
+    [navController release];
  61
+    
  62
+    // Unarchive the navigation controller and ensure that our UINavigationBar subclass is used.
  63
+    NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
  64
+    [unarchiver setClass:[SCNavigationBar class] forClassName:@"UINavigationBar"];
  65
+    UINavigationController *customizedNavController = [unarchiver decodeObjectForKey:@"root"];
  66
+    [unarchiver finishDecoding];
  67
+    [unarchiver release];
  68
+    
  69
+    // Modify the navigation bar to have a background image.
  70
+    SCNavigationBar *navBar = (SCNavigationBar *)[customizedNavController navigationBar];
  71
+    [navBar setTintColor:[UIColor colorWithRed:0.39 green:0.72 blue:0.62 alpha:1.0]];
  72
+    [navBar setBackgroundImage:[UIImage imageNamed:@"navigation-bar-bg.png"] forBarMetrics:UIBarMetricsDefault];
  73
+    [navBar setBackgroundImage:[UIImage imageNamed:@"navigation-bar-bg-landscape.png"] forBarMetrics:UIBarMetricsLandscapePhone];
  74
+
  75
+    return customizedNavController;
  76
+}
  77
+
38 78
 @end
17  Classes/SCAppUtils.h
... ...
@@ -1,17 +0,0 @@
1  
-/*
2  
- * Copyright (c) 2010-2010 Sebastian Celis
3  
- * All rights reserved.
4  
- */
5  
-
6  
-#import <UIKit/UIKit.h>
7  
-
8  
-#define kSCNavigationBarBackgroundImageTag 6183746
9  
-#define kSCNavigationBarTintColor [UIColor colorWithRed:0.39 green:0.72 blue:0.62 alpha:1.0]
10  
-
11  
-@interface SCAppUtils : NSObject
12  
-{
13  
-}
14  
-
15  
-+ (void)customizeNavigationController:(UINavigationController *)navController;
16  
-
17  
-@end
32  Classes/SCAppUtils.m
... ...
@@ -1,32 +0,0 @@
1  
-/*
2  
- * Copyright (c) 2010-2010 Sebastian Celis
3  
- * All rights reserved.
4  
- */
5  
-
6  
-#import "SCAppUtils.h"
7  
-
8  
-@implementation SCAppUtils
9  
-
10  
-+ (void)customizeNavigationController:(UINavigationController *)navController
11  
-{
12  
-    UINavigationBar *navBar = [navController navigationBar];
13  
-    [navBar setTintColor:kSCNavigationBarTintColor];
14  
-    
15  
-    if ([navBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)])
16  
-    {
17  
-        [navBar setBackgroundImage:[UIImage imageNamed:@"navigation-bar-bg.png"] forBarMetrics:UIBarMetricsDefault];
18  
-    }
19  
-    else
20  
-    {
21  
-        UIImageView *imageView = (UIImageView *)[navBar viewWithTag:kSCNavigationBarBackgroundImageTag];
22  
-        if (imageView == nil)
23  
-        {
24  
-            imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navigation-bar-bg.png"]];
25  
-            [imageView setTag:kSCNavigationBarBackgroundImageTag];
26  
-            [navBar insertSubview:imageView atIndex:0];
27  
-            [imageView release];
28  
-        }
29  
-    }
30  
-}
31  
-
32  
-@end
14  Classes/SCClassUtils.h
... ...
@@ -1,14 +0,0 @@
1  
-/*
2  
- * Copyright (c) 2010-2010 Sebastian Celis
3  
- * All rights reserved.
4  
- */
5  
-
6  
-#import <Foundation/Foundation.h>
7  
-
8  
-@interface SCClassUtils : NSObject
9  
-{
10  
-}
11  
-
12  
-+ (void)swizzleSelector:(SEL)orig ofClass:(Class)c withSelector:(SEL)new;
13  
-
14  
-@end
31  Classes/SCClassUtils.m
... ...
@@ -1,31 +0,0 @@
1  
-/*
2  
- * Copyright (c) 2010-2010 Sebastian Celis
3  
- * All rights reserved.
4  
- */
5  
-
6  
-#import "SCClassUtils.h"
7  
-
8  
-#if OBJC_API_VERSION >= 2
9  
-#import <objc/runtime.h>
10  
-#else
11  
-#import <objc/objc-class.h>
12  
-#endif
13  
-
14  
-@implementation SCClassUtils
15  
-
16  
-+ (void)swizzleSelector:(SEL)orig ofClass:(Class)c withSelector:(SEL)new;
17  
-{
18  
-    Method origMethod = class_getInstanceMethod(c, orig);
19  
-    Method newMethod = class_getInstanceMethod(c, new);
20  
-    
21  
-    if (class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod)))
22  
-    {
23  
-        class_replaceMethod(c, new, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
24  
-    }
25  
-    else
26  
-    {
27  
-        method_exchangeImplementations(origMethod, newMethod);
28  
-    }
29  
-}
30  
-
31  
-@end
15  Classes/SCNavigationBar.h
... ...
@@ -0,0 +1,15 @@
  1
+//
  2
+//  SCNavigationBar.h
  3
+//  ExampleNavBarBackground
  4
+//
  5
+//  Created by Sebastian Celis on 3/1/2012.
  6
+//  Copyright 2012-2012 Sebastian Celis. All rights reserved.
  7
+//
  8
+
  9
+#import <UIKit/UIKit.h>
  10
+
  11
+@interface SCNavigationBar : UINavigationBar
  12
+
  13
+- (void)setBackgroundImage:(UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics;
  14
+
  15
+@end
97  Classes/SCNavigationBar.m
... ...
@@ -0,0 +1,97 @@
  1
+//
  2
+//  SCNavigationBar.m
  3
+//  ExampleNavBarBackground
  4
+//
  5
+//  Created by Sebastian Celis on 3/1/2012.
  6
+//  Copyright 2012-2012 Sebastian Celis. All rights reserved.
  7
+//
  8
+
  9
+#import "SCNavigationBar.h"
  10
+
  11
+@interface SCNavigationBar ()
  12
+@property (nonatomic, retain) UIImageView *backgroundImageView;
  13
+@property (nonatomic, retain) NSMutableDictionary *backgroundImages;
  14
+- (void)updateBackgroundImage;
  15
+@end
  16
+
  17
+
  18
+@implementation SCNavigationBar
  19
+
  20
+@synthesize backgroundImages = _backgroundImages;
  21
+@synthesize backgroundImageView = _backgroundImageView;
  22
+
  23
+#pragma mark - View Lifecycle
  24
+
  25
+- (void)dealloc
  26
+{
  27
+    [_backgroundImages release];
  28
+    [_backgroundImageView release];
  29
+    [super dealloc];
  30
+}
  31
+
  32
+#pragma mark - Background Image
  33
+
  34
+- (NSMutableDictionary *)backgroundImages
  35
+{
  36
+    if (_backgroundImages == nil)
  37
+    {
  38
+        _backgroundImages = [[NSMutableDictionary alloc] init];
  39
+    }
  40
+    
  41
+    return _backgroundImages;
  42
+}
  43
+
  44
+- (UIImageView *)backgroundImageView
  45
+{
  46
+    if (_backgroundImageView == nil)
  47
+    {
  48
+        _backgroundImageView = [[UIImageView alloc] initWithFrame:[self bounds]];
  49
+        [_backgroundImageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
  50
+        [self insertSubview:_backgroundImageView atIndex:0];
  51
+    }
  52
+    
  53
+    return _backgroundImageView;
  54
+}
  55
+
  56
+- (void)setBackgroundImage:(UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics
  57
+{
  58
+    if ([UINavigationBar instancesRespondToSelector:@selector(setBackgroundImage:forBarMetrics:)])
  59
+    {
  60
+        [self setBackgroundImage:backgroundImage forBarMetrics:barMetrics];
  61
+    }
  62
+    else
  63
+    {
  64
+        [[self backgroundImages] setObject:backgroundImage forKey:[NSNumber numberWithInt:barMetrics]];
  65
+        [self updateBackgroundImage];
  66
+    }
  67
+}
  68
+
  69
+- (void)updateBackgroundImage
  70
+{
  71
+    UIBarMetrics metrics = ([self bounds].size.height > 40.0) ? UIBarMetricsDefault : UIBarMetricsLandscapePhone;
  72
+    UIImage *image = [[self backgroundImages] objectForKey:[NSNumber numberWithInt:metrics]];
  73
+    if (image == nil && metrics != UIBarMetricsDefault)
  74
+    {
  75
+        image = [[self backgroundImages] objectForKey:[NSNumber numberWithInt:UIBarMetricsDefault]];
  76
+    }
  77
+    
  78
+    if (image != nil)
  79
+    {
  80
+        [[self backgroundImageView] setImage:image];
  81
+    }
  82
+}
  83
+
  84
+#pragma mark - Layout
  85
+
  86
+- (void)layoutSubviews
  87
+{
  88
+    [super layoutSubviews];
  89
+    
  90
+    if (_backgroundImageView != nil)
  91
+    {
  92
+        [self updateBackgroundImage];
  93
+        [self sendSubviewToBack:_backgroundImageView];
  94
+    }
  95
+}
  96
+
  97
+@end
13  Classes/SCTestTableViewController.h
... ...
@@ -1,12 +1,13 @@
1  
-/*
2  
- * Copyright (c) 2010-2010 Sebastian Celis
3  
- * All rights reserved.
4  
- */
  1
+//
  2
+//  SCTestTableViewController.h
  3
+//  ExampleNavBarBackground
  4
+//
  5
+//  Created by Sebastian Celis on 6/7/2010.
  6
+//  Copyright 2010-2012 Sebastian Celis. All rights reserved.
  7
+//
5 8
 
6 9
 #import <UIKit/UIKit.h>
7 10
 
8 11
 @interface SCTestTableViewController : UITableViewController <UITableViewDataSource, UITableViewDelegate>
9  
-{
10  
-}
11 12
 
12 13
 @end
28  Classes/SCTestTableViewController.m
... ...
@@ -1,18 +1,20 @@
1  
-/*
2  
- * Copyright (c) 2010-2010 Sebastian Celis
3  
- * All rights reserved.
4  
- */
  1
+//
  2
+//  SCTestTableViewController.m
  3
+//  ExampleNavBarBackground
  4
+//
  5
+//  Created by Sebastian Celis on 6/7/2010.
  6
+//  Copyright 2010-2012 Sebastian Celis. All rights reserved.
  7
+//
5 8
 
6 9
 #import "SCTestTableViewController.h"
7 10
 
8 11
 @implementation SCTestTableViewController
9 12
 
10  
-#pragma mark -
11  
-#pragma mark View Lifecycle
  13
+#pragma mark - Controller Lifecycle
12 14
 
13 15
 - (id)initWithStyle:(UITableViewStyle)style
14 16
 {
15  
-    if (self = [super initWithStyle:style])
  17
+    if ((self = [super initWithStyle:style]))
16 18
     {
17 19
         [self setTitle:@"Test Table View"];
18 20
     }
@@ -20,13 +22,14 @@ - (id)initWithStyle:(UITableViewStyle)style
20 22
     return self;
21 23
 }
22 24
 
23  
-- (void)dealloc
  25
+#pragma mark - Rotation
  26
+
  27
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
24 28
 {
25  
-    [super dealloc];
  29
+    return YES;
26 30
 }
27 31
 
28  
-#pragma mark -
29  
-#pragma mark UITableViewDataSource
  32
+#pragma mark - UITableViewDataSource
30 33
 
31 34
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
32 35
 {
@@ -47,8 +50,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
47 50
     return cell;
48 51
 }
49 52
 
50  
-#pragma mark -
51  
-#pragma mark UITableViewDelegate
  53
+#pragma mark - UITableViewDelegate
52 54
 
53 55
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
54 56
 {
13  Classes/UINavigationBar+SCBackgroundImage.h
... ...
@@ -1,13 +0,0 @@
1  
-/*
2  
- * Copyright (c) 2010-2010 Sebastian Celis
3  
- * All rights reserved.
4  
- */
5  
-
6  
-#import <UIKit/UIKit.h>
7  
-
8  
-@interface UINavigationBar (SCBackgroundImage)
9  
-
10  
-- (void)scInsertSubview:(UIView *)view atIndex:(NSInteger)index;
11  
-- (void)scSendSubviewToBack:(UIView *)view;
12  
-
13  
-@end
33  Classes/UINavigationBar+SCBackgroundImage.m
... ...
@@ -1,33 +0,0 @@
1  
-/*
2  
- * Copyright (c) 2010-2010 Sebastian Celis
3  
- * All rights reserved.
4  
- */
5  
-
6  
-#import "UINavigationBar+SCBackgroundImage.h"
7  
-#import "SCAppUtils.h"
8  
-
9  
-@implementation UINavigationBar (SCBackgroundImage)
10  
-
11  
-- (void)scInsertSubview:(UIView *)view atIndex:(NSInteger)index
12  
-{
13  
-    [self scInsertSubview:view atIndex:index];
14  
-    
15  
-    UIView *backgroundImageView = [self viewWithTag:kSCNavigationBarBackgroundImageTag];
16  
-    if (backgroundImageView != nil)
17  
-    {
18  
-        [self scSendSubviewToBack:backgroundImageView];
19  
-    }
20  
-}
21  
-
22  
-- (void)scSendSubviewToBack:(UIView *)view
23  
-{
24  
-    [self scSendSubviewToBack:view];
25  
-    
26  
-    UIView *backgroundImageView = [self viewWithTag:kSCNavigationBarBackgroundImageTag];
27  
-    if (backgroundImageView != nil)
28  
-    {
29  
-        [self scSendSubviewToBack:backgroundImageView];
30  
-    }
31  
-}
32  
-
33  
-@end
7  ExampleNavBarBackground-Info.plist
@@ -26,5 +26,12 @@
26 26
 	<true/>
27 27
 	<key>NSMainNibFile</key>
28 28
 	<string>MainWindow</string>
  29
+	<key>UISupportedInterfaceOrientations</key>
  30
+	<array>
  31
+		<string>UIInterfaceOrientationPortrait</string>
  32
+		<string>UIInterfaceOrientationPortraitUpsideDown</string>
  33
+		<string>UIInterfaceOrientationLandscapeLeft</string>
  34
+		<string>UIInterfaceOrientationLandscapeRight</string>
  35
+	</array>
29 36
 </dict>
30 37
 </plist>
30  ExampleNavBarBackground.xcodeproj/project.pbxproj
@@ -12,9 +12,8 @@
12 12
 		1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
13 13
 		1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
14 14
 		28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; };
15  
-		63D9C27211BD49CD007A1AD0 /* SCAppUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 63D9C27111BD49CD007A1AD0 /* SCAppUtils.m */; };
16  
-		63D9C27511BD4A37007A1AD0 /* UINavigationBar+SCBackgroundImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 63D9C27411BD4A37007A1AD0 /* UINavigationBar+SCBackgroundImage.m */; };
17  
-		63D9C27811BD4A6B007A1AD0 /* SCClassUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 63D9C27711BD4A6B007A1AD0 /* SCClassUtils.m */; };
  15
+		6340A63715006379004A5FEF /* navigation-bar-bg-landscape.png in Resources */ = {isa = PBXBuildFile; fileRef = 6340A63615006379004A5FEF /* navigation-bar-bg-landscape.png */; };
  16
+		63D9C27511BD4A37007A1AD0 /* SCNavigationBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 63D9C27411BD4A37007A1AD0 /* SCNavigationBar.m */; };
18 17
 		63D9C2B411BD4BDC007A1AD0 /* SCTestTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 63D9C2B311BD4BDC007A1AD0 /* SCTestTableViewController.m */; };
19 18
 		63D9C30111BD50D9007A1AD0 /* navigation-bar-bg.png in Resources */ = {isa = PBXBuildFile; fileRef = 63D9C30011BD50D9007A1AD0 /* navigation-bar-bg.png */; };
20 19
 /* End PBXBuildFile section */
@@ -28,12 +27,9 @@
28 27
 		28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; };
29 28
 		29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
30 29
 		32CA4F630368D1EE00C91783 /* ExampleNavBarBackground_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleNavBarBackground_Prefix.pch; sourceTree = "<group>"; };
31  
-		63D9C27011BD49CD007A1AD0 /* SCAppUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCAppUtils.h; sourceTree = "<group>"; };
32  
-		63D9C27111BD49CD007A1AD0 /* SCAppUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCAppUtils.m; sourceTree = "<group>"; };
33  
-		63D9C27311BD4A37007A1AD0 /* UINavigationBar+SCBackgroundImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationBar+SCBackgroundImage.h"; sourceTree = "<group>"; };
34  
-		63D9C27411BD4A37007A1AD0 /* UINavigationBar+SCBackgroundImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationBar+SCBackgroundImage.m"; sourceTree = "<group>"; };
35  
-		63D9C27611BD4A6B007A1AD0 /* SCClassUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCClassUtils.h; sourceTree = "<group>"; };
36  
-		63D9C27711BD4A6B007A1AD0 /* SCClassUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCClassUtils.m; sourceTree = "<group>"; };
  30
+		6340A63615006379004A5FEF /* navigation-bar-bg-landscape.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "navigation-bar-bg-landscape.png"; sourceTree = "<group>"; };
  31
+		63D9C27311BD4A37007A1AD0 /* SCNavigationBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCNavigationBar.h; sourceTree = "<group>"; };
  32
+		63D9C27411BD4A37007A1AD0 /* SCNavigationBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCNavigationBar.m; sourceTree = "<group>"; };
37 33
 		63D9C2B211BD4BDC007A1AD0 /* SCTestTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCTestTableViewController.h; sourceTree = "<group>"; };
38 34
 		63D9C2B311BD4BDC007A1AD0 /* SCTestTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCTestTableViewController.m; sourceTree = "<group>"; };
39 35
 		63D9C30011BD50D9007A1AD0 /* navigation-bar-bg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "navigation-bar-bg.png"; sourceTree = "<group>"; };
@@ -58,14 +54,10 @@
58 54
 			children = (
59 55
 				1D3623240D0F684500981E51 /* SCAppDelegate.h */,
60 56
 				1D3623250D0F684500981E51 /* SCAppDelegate.m */,
61  
-				63D9C27011BD49CD007A1AD0 /* SCAppUtils.h */,
62  
-				63D9C27111BD49CD007A1AD0 /* SCAppUtils.m */,
63  
-				63D9C27611BD4A6B007A1AD0 /* SCClassUtils.h */,
64  
-				63D9C27711BD4A6B007A1AD0 /* SCClassUtils.m */,
  57
+				63D9C27311BD4A37007A1AD0 /* SCNavigationBar.h */,
  58
+				63D9C27411BD4A37007A1AD0 /* SCNavigationBar.m */,
65 59
 				63D9C2B211BD4BDC007A1AD0 /* SCTestTableViewController.h */,
66 60
 				63D9C2B311BD4BDC007A1AD0 /* SCTestTableViewController.m */,
67  
-				63D9C27311BD4A37007A1AD0 /* UINavigationBar+SCBackgroundImage.h */,
68  
-				63D9C27411BD4A37007A1AD0 /* UINavigationBar+SCBackgroundImage.m */,
69 61
 			);
70 62
 			path = Classes;
71 63
 			sourceTree = "<group>";
@@ -103,6 +95,7 @@
103 95
 			isa = PBXGroup;
104 96
 			children = (
105 97
 				63D9C30011BD50D9007A1AD0 /* navigation-bar-bg.png */,
  98
+				6340A63615006379004A5FEF /* navigation-bar-bg-landscape.png */,
106 99
 				28AD733E0D9D9553002E5188 /* MainWindow.xib */,
107 100
 				8D1107310486CEB800E47090 /* ExampleNavBarBackground-Info.plist */,
108 101
 			);
@@ -144,7 +137,7 @@
144 137
 		29B97313FDCFA39411CA2CEA /* Project object */ = {
145 138
 			isa = PBXProject;
146 139
 			attributes = {
147  
-				LastUpgradeCheck = 0420;
  140
+				LastUpgradeCheck = 0430;
148 141
 			};
149 142
 			buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "ExampleNavBarBackground" */;
150 143
 			compatibilityVersion = "Xcode 3.2";
@@ -169,6 +162,7 @@
169 162
 			files = (
170 163
 				28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */,
171 164
 				63D9C30111BD50D9007A1AD0 /* navigation-bar-bg.png in Resources */,
  165
+				6340A63715006379004A5FEF /* navigation-bar-bg-landscape.png in Resources */,
172 166
 			);
173 167
 			runOnlyForDeploymentPostprocessing = 0;
174 168
 		};
@@ -181,9 +175,7 @@
181 175
 			files = (
182 176
 				1D60589B0D05DD56006BFB54 /* main.m in Sources */,
183 177
 				1D3623260D0F684500981E51 /* SCAppDelegate.m in Sources */,
184  
-				63D9C27211BD49CD007A1AD0 /* SCAppUtils.m in Sources */,
185  
-				63D9C27511BD4A37007A1AD0 /* UINavigationBar+SCBackgroundImage.m in Sources */,
186  
-				63D9C27811BD4A6B007A1AD0 /* SCClassUtils.m in Sources */,
  178
+				63D9C27511BD4A37007A1AD0 /* SCNavigationBar.m in Sources */,
187 179
 				63D9C2B411BD4BDC007A1AD0 /* SCTestTableViewController.m in Sources */,
188 180
 			);
189 181
 			runOnlyForDeploymentPostprocessing = 0;
19  main.m
... ...
@@ -1,20 +1,15 @@
1  
-/*
2  
- * Copyright (c) 2010-2010 Sebastian Celis
3  
- * All rights reserved.
4  
- */
  1
+//
  2
+//  main.m
  3
+//  ExampleNavBarBackground
  4
+//
  5
+//  Created by Sebastian Celis on 6/7/2010.
  6
+//  Copyright 2010-2012 Sebastian Celis. All rights reserved.
  7
+//
5 8
 
6 9
 #import <UIKit/UIKit.h>
7  
-#import "SCClassUtils.h"
8 10
 
9 11
 int main(int argc, char *argv[])
10 12
 {
11  
-    [SCClassUtils swizzleSelector:@selector(insertSubview:atIndex:)
12  
-                          ofClass:[UINavigationBar class]
13  
-                     withSelector:@selector(scInsertSubview:atIndex:)];
14  
-    [SCClassUtils swizzleSelector:@selector(sendSubviewToBack:)
15  
-                          ofClass:[UINavigationBar class]
16  
-                     withSelector:@selector(scSendSubviewToBack:)];
17  
-    
18 13
     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
19 14
     int retVal = UIApplicationMain(argc, argv, nil, nil);
20 15
     [pool release];
BIN  navigation-bar-bg-landscape.png

0 notes on commit bce0b4d

Please sign in to comment.
Something went wrong with that request. Please try again.