Permalink
Browse files

Merge pull request #11 from JanC/master

fix for #10
  • Loading branch information...
2 parents e4935cb + 560c7b3 commit 79dba946e1b3585b6ea94b3f3c77294e7d541a95 @sarperdag committed Jul 27, 2012
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
+ 0159A72915C14CE900F71157 /* UIViewController+SEViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0159A72815C14CE900F71157 /* UIViewController+SEViewController.m */; };
7514C0CC14654F0700FEF1E6 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7514C0CB14654F0700FEF1E6 /* UIKit.framework */; };
7514C0CE14654F0700FEF1E6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7514C0CD14654F0700FEF1E6 /* Foundation.framework */; };
7514C0D014654F0700FEF1E6 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7514C0CF14654F0700FEF1E6 /* CoreGraphics.framework */; };
@@ -21,7 +22,6 @@
7514C12B1465AA4900FEF1E6 /* ChildViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7514C1291465AA4900FEF1E6 /* ChildViewController.xib */; };
7514C12E1465BC5000FEF1E6 /* navbtn_home.png in Resources */ = {isa = PBXBuildFile; fileRef = 7514C12C1465BC5000FEF1E6 /* navbtn_home.png */; };
7514C12F1465BC5000FEF1E6 /* navbtn_home@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7514C12D1465BC5000FEF1E6 /* navbtn_home@2x.png */; };
- 7514C1321465BC9C00FEF1E6 /* SEViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7514C1311465BC9C00FEF1E6 /* SEViewController.m */; };
75272FB51465FC1D004F0CF3 /* youtube.png in Resources */ = {isa = PBXBuildFile; fileRef = 75272FAF1465FC1D004F0CF3 /* youtube.png */; };
75272FB61465FC1D004F0CF3 /* twitter.png in Resources */ = {isa = PBXBuildFile; fileRef = 75272FB01465FC1D004F0CF3 /* twitter.png */; };
75272FB71465FC1D004F0CF3 /* rss.png in Resources */ = {isa = PBXBuildFile; fileRef = 75272FB11465FC1D004F0CF3 /* rss.png */; };
@@ -36,6 +36,8 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
+ 0159A72715C14CE900F71157 /* UIViewController+SEViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+SEViewController.h"; sourceTree = "<group>"; };
+ 0159A72815C14CE900F71157 /* UIViewController+SEViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+SEViewController.m"; sourceTree = "<group>"; };
7514C0C714654F0700FEF1E6 /* SESpringBoardDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SESpringBoardDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
7514C0CB14654F0700FEF1E6 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
7514C0CD14654F0700FEF1E6 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -58,8 +60,6 @@
7514C1291465AA4900FEF1E6 /* ChildViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ChildViewController.xib; sourceTree = "<group>"; };
7514C12C1465BC5000FEF1E6 /* navbtn_home.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = navbtn_home.png; sourceTree = "<group>"; };
7514C12D1465BC5000FEF1E6 /* navbtn_home@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "navbtn_home@2x.png"; sourceTree = "<group>"; };
- 7514C1301465BC9C00FEF1E6 /* SEViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SEViewController.h; sourceTree = "<group>"; };
- 7514C1311465BC9C00FEF1E6 /* SEViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SEViewController.m; sourceTree = "<group>"; };
75272FAF1465FC1D004F0CF3 /* youtube.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = youtube.png; sourceTree = "<group>"; };
75272FB01465FC1D004F0CF3 /* twitter.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = twitter.png; sourceTree = "<group>"; };
75272FB11465FC1D004F0CF3 /* rss.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = rss.png; sourceTree = "<group>"; };
@@ -153,8 +153,8 @@
7514C0EA14654F5C00FEF1E6 /* SEMenuItem.m */,
7514C0EC14654F9B00FEF1E6 /* SESpringBoard.h */,
7514C0ED14654F9B00FEF1E6 /* SESpringBoard.m */,
- 7514C1301465BC9C00FEF1E6 /* SEViewController.h */,
- 7514C1311465BC9C00FEF1E6 /* SEViewController.m */,
+ 0159A72715C14CE900F71157 /* UIViewController+SEViewController.h */,
+ 0159A72815C14CE900F71157 /* UIViewController+SEViewController.m */,
);
name = SESpringBoard;
path = SESpringBoardDemo/SESpringBoard;
@@ -259,7 +259,7 @@
7514C0EB14654F5C00FEF1E6 /* SEMenuItem.m in Sources */,
7514C0EE14654F9C00FEF1E6 /* SESpringBoard.m in Sources */,
7514C12A1465AA4900FEF1E6 /* ChildViewController.m in Sources */,
- 7514C1321465BC9C00FEF1E6 /* SEViewController.m in Sources */,
+ 0159A72915C14CE900F71157 /* UIViewController+SEViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -6,10 +6,9 @@
// Copyright (c) 2011 Sarp Erdag. All rights reserved.
//
-#import "SEViewController.h"
-@interface ChildViewController : SEViewController {
+@interface ChildViewController : UIViewController {
}
@@ -7,7 +7,7 @@
//
#import "SESpringBoard.h"
-#import "SEViewController.h"
+#import "UIViewController+SEViewController.h"
@implementation SESpringBoard
@@ -92,7 +92,7 @@ - (id) initWithTitle:(NSString *)boardTitle items:(NSMutableArray *)menuItems im
[itemsContainer setContentSize:CGSizeMake(numberOfPages*300, itemsContainer.frame.size.height)];
[itemsContainer release];
-
+
// add a page control representing the page the scrollview controls
pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 433, 320, 20)];
if (numberOfPages > 1) {
@@ -135,7 +135,7 @@ - (CGAffineTransform)offscreenQuadrantTransformForView:(UIView *)theView {
#pragma mark - MenuItem Delegate Methods
-- (void)launch:(int)tag :viewController {
+- (void)launch:(int)index:(UIViewController *)viewController {
// if the springboard is in editing mode, do not launch any view controller
if (isInEditingMode)
@@ -146,12 +146,15 @@ - (void)launch:(int)tag :viewController {
// create a navigation bar
nav = [UINavigationController alloc];
- SEViewController *vc = viewController;
+
+
// manually trigger the appear method
[viewController viewDidAppear:YES];
- vc.launcherImage = launcher;
+
+ [viewController setupCloseButtonWithImage:launcher];
+
[nav initWithRootViewController:viewController];
[nav viewDidAppear:YES];
@@ -190,13 +193,13 @@ - (void)removeFromSpringboard:(int)index {
int mult = ((int)menuItem.frame.origin.y) / 95;
int add = ((int)menuItem.frame.origin.x % 300)/100;
int pageSpecificIndex = (mult*3) + add;
- int remainingNumberOfItemsInPage = numberOfItemsInCurrentPage-pageSpecificIndex;
+ int remainingNumberOfItemsInPage = numberOfItemsInCurrentPage-pageSpecificIndex;
// Select the items listed after the deleted menu item
// and move each of the ones on the current page, one step back.
// The first item of each row becomes the last item of the previous row.
for (int i = index+1; i<[items count]; i++) {
- SEMenuItem *item = [items objectAtIndex:i];
+ SEMenuItem *item = [items objectAtIndex:i];
[UIView animateWithDuration:0.2 animations:^{
// Only reposition the items in the current page, coming after the current item
@@ -206,14 +209,14 @@ - (void)removeFromSpringboard:(int)index {
// Check if it is the first item in the row
if (intVal % 3 == 0)
[item setFrame:CGRectMake(item.frame.origin.x+200, item.frame.origin.y-95, item.frame.size.width, item.frame.size.height)];
- else
+ else
[item setFrame:CGRectMake(item.frame.origin.x-100, item.frame.origin.y, item.frame.size.width, item.frame.size.height)];
- }
+ }
- // Update the tag to match with the index. Since the an item is being removed from the array,
+ // Update the tag to match with the index. Since the an item is being removed from the array,
// all the items' tags coming after the current item has to be decreased by 1.
[item updateTag:item.tag-1];
- }];
+ }];
}
// remove the item from the array of items
[items removeObjectAtIndex:index];
@@ -223,7 +226,7 @@ - (void)removeFromSpringboard:(int)index {
}
- (void)closeViewEventHandler: (NSNotification *) notification {
- UIView *viewToRemove = (UIView *) notification.object;
+ UIView *viewToRemove = (UIView *) notification.object;
[UIView animateWithDuration:.3f animations:^{
viewToRemove.alpha = 0.f;
viewToRemove.transform = CGAffineTransformMakeScale(.1f, .1f);
@@ -1,15 +0,0 @@
-//
-// SEViewController.h
-// SESpringBoardDemo
-//
-// Created by Sarp Erdag on 11/5/11.
-// Copyright (c) 2011 Sarp Erdag. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-@interface SEViewController : UIViewController
-
-@property (nonatomic, assign) UIImage *launcherImage;
-
-@end
@@ -0,0 +1,16 @@
+//
+// UIViewController+SEViewController.h
+// SESpringBoardDemo
+//
+// Created by jac on 7/26/12.
+//
+//
+
+#import <UIKit/UIKit.h>
+
+@interface UIViewController (SEViewController)
+
+
+-(void) setupCloseButtonWithImage:(UIImage *) closeImage;
+
+@end
@@ -1,39 +1,28 @@
//
-// SEViewController.m
+// UIViewController+SEViewController.m
// SESpringBoardDemo
//
-// Created by Sarp Erdag on 11/5/11.
-// Copyright (c) 2011 Sarp Erdag. All rights reserved.
+// Created by jac on 7/26/12.
+//
//
-#import "SEViewController.h"
-
-@implementation SEViewController
+#import "UIViewController+SEViewController.h"
-@synthesize launcherImage;
+@implementation UIViewController (SEViewController)
- (void)quitView: (id) sender {
[[NSNotificationCenter defaultCenter] postNotificationName:@"closeView" object:self.navigationController.view];
}
-
-- (void)viewDidLoad
-{
- [super viewDidLoad];
+-(void) setupCloseButtonWithImage:(UIImage *) closeImage {
// add a button to the navigation bar to switch back to the springboard interface (home)
UIButton *btn = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
- [btn setBackgroundImage:launcherImage forState:UIControlStateNormal];
+ [btn setBackgroundImage: closeImage forState:UIControlStateNormal];
[btn setFrame:CGRectMake(0, 0, 41, 33)];
[btn addTarget:self action:@selector(quitView:)forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *showLauncher = [[UIBarButtonItem alloc] initWithCustomView:btn];
self.navigationItem.leftBarButtonItem = showLauncher;
- [showLauncher release];
+
}
-
-- (void)dealloc {
- [super dealloc];
-}
-
-
@end

0 comments on commit 79dba94

Please sign in to comment.