From e79ada79882fc4de2117011a49f17da9d1a2e459 Mon Sep 17 00:00:00 2001 From: Oleksandr Dodatko Date: Tue, 31 Jan 2012 13:15:26 +0200 Subject: [PATCH 01/17] Removed obsolete init. Added UIViewController calls forwarding --- .../CLCascadeNavigationController.m | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m b/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m index 6a713a1..3987651 100644 --- a/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m +++ b/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m @@ -79,6 +79,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration { [_cascadeView updateContentLayoutToInterfaceOrientation:interfaceOrientation duration:duration]; + //dodikk - blocks are available since iOS4 } From fc73f77a04b1965de141a8213623df6e7d37f8e9 Mon Sep 17 00:00:00 2001 From: Oleksandr Dodatko Date: Tue, 31 Jan 2012 13:16:04 +0200 Subject: [PATCH 02/17] Remonde obsolete init. Added calls forwarding --- .../CLCascadeNavigationController.m | 51 +++++++++++++++---- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m b/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m index 3987651..6438f27 100644 --- a/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m +++ b/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m @@ -23,14 +23,6 @@ @implementation CLCascadeNavigationController @synthesize viewControllers = _viewControllers; @synthesize leftInset, widerLeftInset; -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil -{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - // Custom initialization - } - return self; -} - (void)dealloc { @@ -77,9 +69,48 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface return YES; } -- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration { - [_cascadeView updateContentLayoutToInterfaceOrientation:interfaceOrientation duration:duration]; +-(void)willRotateToInterfaceOrientation:( UIInterfaceOrientation )toInterfaceOrientation_ + duration:( NSTimeInterval )duration_ +{ + //dodikk - blocks are available since iOS4 + [ self.viewControllers enumerateObjectsUsingBlock: ^void(id obj_, NSUInteger idx_, BOOL *stop_) + { + UIViewController* controller_ = (UIViewController*)obj_; + [ controller_ willRotateToInterfaceOrientation: toInterfaceOrientation_ + duration: duration_ ]; + + *stop_ = NO; + } ]; +} + +-(void)didRotateFromInterfaceOrientation:( UIInterfaceOrientation )fromInterfaceOrientation_ +{ + //dodikk - blocks are available since iOS4 + [ self.viewControllers enumerateObjectsUsingBlock: ^void(id obj_, NSUInteger idx_, BOOL *stop_) + { + UIViewController* controller_ = (UIViewController*)obj_; + [ controller_ didRotateFromInterfaceOrientation: fromInterfaceOrientation_ ]; + + *stop_ = NO; + } ]; +} + +- (void)willAnimateRotationToInterfaceOrientation:( UIInterfaceOrientation )interfaceOrientation_ + duration:( NSTimeInterval )duration_ +{ //dodikk - blocks are available since iOS4 + [ self.viewControllers enumerateObjectsUsingBlock: ^void(id obj_, NSUInteger idx_, BOOL *stop_) + { + UIViewController* controller_ = (UIViewController*)obj_; + [ controller_ willAnimateRotationToInterfaceOrientation: interfaceOrientation_ + duration: duration_ ]; + + *stop_ = NO; + } ]; + + + [_cascadeView updateContentLayoutToInterfaceOrientation: interfaceOrientation_ + duration: duration_ ]; } From 4d14f4f51de23a0b6f0face9c6cae119ccaf2218 Mon Sep 17 00:00:00 2001 From: Oleksandr Dodatko Date: Tue, 31 Jan 2012 13:16:30 +0200 Subject: [PATCH 03/17] Added size adjustments on layoutSubviews --- .../CLCascadeView.m | 64 ++++++++++++++----- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/src/Cascade/CLCascadeNavigationController/CLCascadeView.m b/src/Cascade/CLCascadeNavigationController/CLCascadeView.m index a634eed..a516030 100644 --- a/src/Cascade/CLCascadeNavigationController/CLCascadeView.m +++ b/src/Cascade/CLCascadeNavigationController/CLCascadeView.m @@ -328,14 +328,40 @@ - (void) unloadInvisiblePages { } -/////////////////////////////////////////////////////////////////////////////////////////////////// -- (void) updateContentLayoutToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration { - // set proper content size +-(void)layoutSubviews +{ + UIInterfaceOrientation interfaceOrientation = [ [ UIApplication sharedApplication ] statusBarOrientation ]; + + + // recalculate pages height and width + [ self setProperSizesForLodedPages: interfaceOrientation ]; + + //dodikk - crash workaround + if ( [ self->_pages isEqual: [ NSNull null ] ] ) + { + return; + } + + [ self->_pages enumerateObjectsUsingBlock: ^void(id obj_, NSUInteger idx_, BOOL *stop_) + { + UIView* page_view_ = ( UIView* )obj_; + [ page_view_ setNeedsLayout ]; + + *stop_ = NO; + } ]; + +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +- (void)updateContentLayoutToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation + duration:(NSTimeInterval)duration +{ [self setProperContentSize]; - // set proper edge inset - [self setProperEdgeInset:YES forInterfaceOrientation:interfaceOrientation]; + [self setProperEdgeInset: YES + forInterfaceOrientation: interfaceOrientation ]; + // recalculate pages height and width - [self setProperSizesForLodedPages: interfaceOrientation]; + [ self setProperSizesForLodedPages: interfaceOrientation ]; } @@ -642,17 +668,21 @@ - (CGSize) calculatePageSize:(UIView*)view { /////////////////////////////////////////////////////////////////////////////////////////////////// -- (void) setProperSizesForLodedPages:(UIInterfaceOrientation)interfaceOrientation { - [_pages enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - if (obj != [NSNull null]) { - UIView* view = (UIView*)obj; - CGRect rect = view.frame; - CGPoint point = [self calculateOriginOfPageAtIndex: idx]; - CGSize size = [self calculatePageSize: obj]; - rect.size = size; - rect.origin = point; - [view setFrame:rect]; - } +-(void)setProperSizesForLodedPages:(UIInterfaceOrientation)interfaceOrientation +{ + [ _pages enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) + { + if (obj != [NSNull null]) + { + UIView* view = (UIView*)obj; + CGRect rect = view.frame; + CGPoint point = [self calculateOriginOfPageAtIndex: idx]; + CGSize size = [self calculatePageSize: obj]; + rect.size = size; + rect.origin = point; + [ view setFrame: rect ]; + [ view setNeedsLayout ]; + } }]; } From 268e1c81cd056ccb8646407327fad27e6be47e53 Mon Sep 17 00:00:00 2001 From: Oleksandr Dodatko Date: Tue, 31 Jan 2012 13:16:44 +0200 Subject: [PATCH 04/17] Removed obsolete code --- src/Cascade/CLCategories/CLCategoriesViewController.m | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Cascade/CLCategories/CLCategoriesViewController.m b/src/Cascade/CLCategories/CLCategoriesViewController.m index ff163de..05c0c77 100644 --- a/src/Cascade/CLCategories/CLCategoriesViewController.m +++ b/src/Cascade/CLCategories/CLCategoriesViewController.m @@ -19,16 +19,6 @@ - (id) initWithNavigationController:(CLCascadeNavigationController*)viewControll return self; } -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil -{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - // Custom initialization - } - return self; -} - - - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. From 360ef3923d08afacd84a734d4e9ea9b3780d608d Mon Sep 17 00:00:00 2001 From: Oleksandr Dodatko Date: Tue, 31 Jan 2012 13:17:20 +0200 Subject: [PATCH 05/17] ievgen - segmentedView related fix --- .../CLCustomViewControllers/CLViewController.m | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Cascade/CLCustomViewControllers/CLViewController.m b/src/Cascade/CLCustomViewControllers/CLViewController.m index 1f12f33..c462bb8 100644 --- a/src/Cascade/CLCustomViewControllers/CLViewController.m +++ b/src/Cascade/CLCustomViewControllers/CLViewController.m @@ -86,10 +86,17 @@ - (void) loadView { NSString *path = [bundle pathForResource:nib ofType:@"nib"]; - if(path) { - self.view = [[bundle loadNibNamed:nib owner:self options:nil] objectAtIndex: 0]; - return; - } + if(path) + { + UIView* view_ = [ [ bundle loadNibNamed: nib owner: self options: nil ] objectAtIndex: 0 ]; + if ( [ view_ isKindOfClass: [ CLSegmentedView class ] ] ) + { + [ (CLSegmentedView*)view_ setViewSize: self.viewSize ]; + } + + self.view = view_; + return; + } } CLSegmentedView* view_ = [[CLSegmentedView alloc] initWithSize: _viewSize]; From 93fb50c0730b1dbbde0b69b93365f16e3380f4a6 Mon Sep 17 00:00:00 2001 From: Oleksandr Dodatko Date: Tue, 31 Jan 2012 13:17:34 +0200 Subject: [PATCH 06/17] Added tableSize adjiustments --- src/Cascade/CLCustomViewControllers/CLWebViewController.h | 2 ++ src/Cascade/CLCustomViewControllers/CLWebViewController.m | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Cascade/CLCustomViewControllers/CLWebViewController.h b/src/Cascade/CLCustomViewControllers/CLWebViewController.h index 43cb213..ac2385a 100644 --- a/src/Cascade/CLCustomViewControllers/CLWebViewController.h +++ b/src/Cascade/CLCustomViewControllers/CLWebViewController.h @@ -23,5 +23,7 @@ * This method fire loadRequest in webView. */ - (void) loadRequest; + +-(void)setTableSize; @end diff --git a/src/Cascade/CLCustomViewControllers/CLWebViewController.m b/src/Cascade/CLCustomViewControllers/CLWebViewController.m index 4a1e402..bca49b1 100644 --- a/src/Cascade/CLCustomViewControllers/CLWebViewController.m +++ b/src/Cascade/CLCustomViewControllers/CLWebViewController.m @@ -25,6 +25,11 @@ - (id) init { return self; } +-(void)setTableSize +{ + _viewSize = CLViewSizeNormal; +} + /////////////////////////////////////////////////////////////////////////////////////////////////// - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil @@ -79,7 +84,7 @@ - (void)viewDidLoad [self setWebView: webView_]; // load request - [self loadRequest]; + // [self loadRequest]; } From 895e126057f36573eef5c68d7acfafb4730ce2ea Mon Sep 17 00:00:00 2001 From: Oleksandr Dodatko Date: Tue, 31 Jan 2012 13:17:44 +0200 Subject: [PATCH 07/17] Added size adjustments --- src/Cascade/Other/CLSegmentedView.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cascade/Other/CLSegmentedView.h b/src/Cascade/Other/CLSegmentedView.h index caea01c..9571445 100644 --- a/src/Cascade/Other/CLSegmentedView.h +++ b/src/Cascade/Other/CLSegmentedView.h @@ -64,7 +64,7 @@ /* * Size of view */ -@property (nonatomic, assign, readonly) CLViewSize viewSize; +@property (nonatomic, assign ) CLViewSize viewSize; - (id) initWithSize:(CLViewSize)size; From 4fceea65675b872e1fe1de3c252c279db3a9026d Mon Sep 17 00:00:00 2001 From: Oleksandr Dodatko Date: Tue, 31 Jan 2012 13:17:52 +0200 Subject: [PATCH 08/17] dodikk - added clang target --- src/Cascade/Cascade.xcodeproj/project.pbxproj | 148 +++++++++++++++++- 1 file changed, 144 insertions(+), 4 deletions(-) diff --git a/src/Cascade/Cascade.xcodeproj/project.pbxproj b/src/Cascade/Cascade.xcodeproj/project.pbxproj index e376976..cef66d1 100644 --- a/src/Cascade/Cascade.xcodeproj/project.pbxproj +++ b/src/Cascade/Cascade.xcodeproj/project.pbxproj @@ -7,6 +7,36 @@ objects = { /* Begin PBXBuildFile section */ + 716E42FE14A1D19C0052AFFB /* CLCascadeNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = B6EA8CC21456D53200817157 /* CLCascadeNavigationController.m */; }; + 716E42FF14A1D19C0052AFFB /* CLCascadeView.m in Sources */ = {isa = PBXBuildFile; fileRef = B6EA8CC41456D53200817157 /* CLCascadeView.m */; }; + 716E430014A1D19C0052AFFB /* CLCategoriesView.m in Sources */ = {isa = PBXBuildFile; fileRef = B6EA8CC71456D53200817157 /* CLCategoriesView.m */; }; + 716E430114A1D19C0052AFFB /* CLCategoriesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B6EA8CC91456D53200817157 /* CLCategoriesViewController.m */; }; + 716E430214A1D19C0052AFFB /* CLTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B6EA8CCC1456D53200817157 /* CLTableViewController.m */; }; + 716E430314A1D19C0052AFFB /* CLViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B6EA8CCE1456D53200817157 /* CLViewController.m */; }; + 716E430414A1D19C0052AFFB /* CLWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B6EA8CD11456D53200817157 /* CLWebViewController.m */; }; + 716E430514A1D19C0052AFFB /* CLSplitCascadeView.m in Sources */ = {isa = PBXBuildFile; fileRef = B6EA8CD41456D53200817157 /* CLSplitCascadeView.m */; }; + 716E430614A1D19C0052AFFB /* CLSplitCascadeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B6EA8CD61456D53200817157 /* CLSplitCascadeViewController.m */; }; + 716E430714A1D19C0052AFFB /* CLBorderShadowView.m in Sources */ = {isa = PBXBuildFile; fileRef = B6EA8CDA1456D53200817157 /* CLBorderShadowView.m */; }; + 716E430814A1D19C0052AFFB /* CLScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = B6EA8CDD1456D53200817157 /* CLScrollView.m */; }; + 716E430914A1D19C0052AFFB /* CLSegmentedView.m in Sources */ = {isa = PBXBuildFile; fileRef = B6EA8CDF1456D53200817157 /* CLSegmentedView.m */; }; + 716E430A14A1D19C0052AFFB /* UIViewController+CLSegmentedView.m in Sources */ = {isa = PBXBuildFile; fileRef = B6EA8CE11456D53200817157 /* UIViewController+CLSegmentedView.m */; }; + 716E430C14A1D19C0052AFFB /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B6EA8CAF1456D25200817157 /* Foundation.framework */; }; + 716E430E14A1D19C0052AFFB /* Cascade.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CBE1456D2EC00817157 /* Cascade.h */; }; + 716E430F14A1D19C0052AFFB /* CLCascadeNavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CC11456D53200817157 /* CLCascadeNavigationController.h */; }; + 716E431014A1D19C0052AFFB /* CLCascadeView.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CC31456D53200817157 /* CLCascadeView.h */; }; + 716E431114A1D19C0052AFFB /* CLCategoriesView.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CC61456D53200817157 /* CLCategoriesView.h */; }; + 716E431214A1D19C0052AFFB /* CLCategoriesViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CC81456D53200817157 /* CLCategoriesViewController.h */; }; + 716E431314A1D19C0052AFFB /* CLTableViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CCB1456D53200817157 /* CLTableViewController.h */; }; + 716E431414A1D19C0052AFFB /* CLViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CCD1456D53200817157 /* CLViewController.h */; }; + 716E431514A1D19C0052AFFB /* CLViewControllerDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CCF1456D53200817157 /* CLViewControllerDelegate.h */; }; + 716E431614A1D19C0052AFFB /* CLWebViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CD01456D53200817157 /* CLWebViewController.h */; }; + 716E431714A1D19C0052AFFB /* CLSplitCascadeView.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CD31456D53200817157 /* CLSplitCascadeView.h */; }; + 716E431814A1D19C0052AFFB /* CLSplitCascadeViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CD51456D53200817157 /* CLSplitCascadeViewController.h */; }; + 716E431914A1D19C0052AFFB /* CLBorderShadowView.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CD91456D53200817157 /* CLBorderShadowView.h */; }; + 716E431A14A1D19C0052AFFB /* CLGlobal.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CDB1456D53200817157 /* CLGlobal.h */; }; + 716E431B14A1D19C0052AFFB /* CLScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CDC1456D53200817157 /* CLScrollView.h */; }; + 716E431C14A1D19C0052AFFB /* CLSegmentedView.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CDE1456D53200817157 /* CLSegmentedView.h */; }; + 716E431D14A1D19C0052AFFB /* UIViewController+CLSegmentedView.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CE01456D53200817157 /* UIViewController+CLSegmentedView.h */; }; B6EA8CB01456D25200817157 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B6EA8CAF1456D25200817157 /* Foundation.framework */; }; B6EA8CBF1456D2EC00817157 /* Cascade.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CBE1456D2EC00817157 /* Cascade.h */; }; B6EA8CE21456D53200817157 /* CLCascadeNavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = B6EA8CC11456D53200817157 /* CLCascadeNavigationController.h */; }; @@ -40,6 +70,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 716E432114A1D19C0052AFFB /* libCascade-clang.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libCascade-clang.a"; sourceTree = BUILT_PRODUCTS_DIR; }; B6EA8CAC1456D25200817157 /* libCascade.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCascade.a; sourceTree = BUILT_PRODUCTS_DIR; }; B6EA8CAF1456D25200817157 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; B6EA8CB31456D25200817157 /* Cascade-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Cascade-Prefix.pch"; sourceTree = ""; }; @@ -76,6 +107,14 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 716E430B14A1D19C0052AFFB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 716E430C14A1D19C0052AFFB /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B6EA8CA91456D25200817157 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -100,6 +139,7 @@ isa = PBXGroup; children = ( B6EA8CAC1456D25200817157 /* libCascade.a */, + 716E432114A1D19C0052AFFB /* libCascade-clang.a */, ); name = Products; sourceTree = ""; @@ -201,6 +241,29 @@ /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ + 716E430D14A1D19C0052AFFB /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 716E430E14A1D19C0052AFFB /* Cascade.h in Headers */, + 716E430F14A1D19C0052AFFB /* CLCascadeNavigationController.h in Headers */, + 716E431014A1D19C0052AFFB /* CLCascadeView.h in Headers */, + 716E431114A1D19C0052AFFB /* CLCategoriesView.h in Headers */, + 716E431214A1D19C0052AFFB /* CLCategoriesViewController.h in Headers */, + 716E431314A1D19C0052AFFB /* CLTableViewController.h in Headers */, + 716E431414A1D19C0052AFFB /* CLViewController.h in Headers */, + 716E431514A1D19C0052AFFB /* CLViewControllerDelegate.h in Headers */, + 716E431614A1D19C0052AFFB /* CLWebViewController.h in Headers */, + 716E431714A1D19C0052AFFB /* CLSplitCascadeView.h in Headers */, + 716E431814A1D19C0052AFFB /* CLSplitCascadeViewController.h in Headers */, + 716E431914A1D19C0052AFFB /* CLBorderShadowView.h in Headers */, + 716E431A14A1D19C0052AFFB /* CLGlobal.h in Headers */, + 716E431B14A1D19C0052AFFB /* CLScrollView.h in Headers */, + 716E431C14A1D19C0052AFFB /* CLSegmentedView.h in Headers */, + 716E431D14A1D19C0052AFFB /* UIViewController+CLSegmentedView.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B6EA8CAA1456D25200817157 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -227,6 +290,23 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ + 716E42FC14A1D19C0052AFFB /* Cascade-clang */ = { + isa = PBXNativeTarget; + buildConfigurationList = 716E431E14A1D19C0052AFFB /* Build configuration list for PBXNativeTarget "Cascade-clang" */; + buildPhases = ( + 716E42FD14A1D19C0052AFFB /* Sources */, + 716E430B14A1D19C0052AFFB /* Frameworks */, + 716E430D14A1D19C0052AFFB /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Cascade-clang"; + productName = Cascade; + productReference = 716E432114A1D19C0052AFFB /* libCascade-clang.a */; + productType = "com.apple.product-type.library.static"; + }; B6EA8CAB1456D25200817157 /* Cascade */ = { isa = PBXNativeTarget; buildConfigurationList = B6EA8CB91456D25200817157 /* Build configuration list for PBXNativeTarget "Cascade" */; @@ -265,11 +345,32 @@ projectRoot = ""; targets = ( B6EA8CAB1456D25200817157 /* Cascade */, + 716E42FC14A1D19C0052AFFB /* Cascade-clang */, ); }; /* End PBXProject section */ /* Begin PBXSourcesBuildPhase section */ + 716E42FD14A1D19C0052AFFB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 716E42FE14A1D19C0052AFFB /* CLCascadeNavigationController.m in Sources */, + 716E42FF14A1D19C0052AFFB /* CLCascadeView.m in Sources */, + 716E430014A1D19C0052AFFB /* CLCategoriesView.m in Sources */, + 716E430114A1D19C0052AFFB /* CLCategoriesViewController.m in Sources */, + 716E430214A1D19C0052AFFB /* CLTableViewController.m in Sources */, + 716E430314A1D19C0052AFFB /* CLViewController.m in Sources */, + 716E430414A1D19C0052AFFB /* CLWebViewController.m in Sources */, + 716E430514A1D19C0052AFFB /* CLSplitCascadeView.m in Sources */, + 716E430614A1D19C0052AFFB /* CLSplitCascadeViewController.m in Sources */, + 716E430714A1D19C0052AFFB /* CLBorderShadowView.m in Sources */, + 716E430814A1D19C0052AFFB /* CLScrollView.m in Sources */, + 716E430914A1D19C0052AFFB /* CLSegmentedView.m in Sources */, + 716E430A14A1D19C0052AFFB /* UIViewController+CLSegmentedView.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; B6EA8CA81456D25200817157 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -293,6 +394,36 @@ /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ + 716E431F14A1D19C0052AFFB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/Cascade.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Cascade/Cascade-Prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "Cascade-clang"; + RUN_CLANG_STATIC_ANALYZER = YES; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 2; + }; + name = Debug; + }; + 716E432014A1D19C0052AFFB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/Cascade.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Cascade/Cascade-Prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "Cascade-clang"; + RUN_CLANG_STATIC_ANALYZER = YES; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 2; + }; + name = Release; + }; B6EA8CB71456D25200817157 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -308,7 +439,7 @@ "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_VERSION = ""; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -316,7 +447,7 @@ "./**", .., ); - IPHONEOS_DEPLOYMENT_TARGET = 5.0; + IPHONEOS_DEPLOYMENT_TARGET = 4.0; SDKROOT = iphoneos; }; name = Debug; @@ -329,7 +460,7 @@ CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_VERSION = ""; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -337,7 +468,7 @@ "./**", .., ); - IPHONEOS_DEPLOYMENT_TARGET = 5.0; + IPHONEOS_DEPLOYMENT_TARGET = 4.0; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; @@ -370,6 +501,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 716E431E14A1D19C0052AFFB /* Build configuration list for PBXNativeTarget "Cascade-clang" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 716E431F14A1D19C0052AFFB /* Debug */, + 716E432014A1D19C0052AFFB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; B6EA8CA61456D25200817157 /* Build configuration list for PBXProject "Cascade" */ = { isa = XCConfigurationList; buildConfigurations = ( From f556dcdcfddaf6ea3af68f67b5547576fc4e8c1c Mon Sep 17 00:00:00 2001 From: Oleksandr Dodatko Date: Thu, 2 Feb 2012 11:31:35 +0200 Subject: [PATCH 09/17] NSNull crash fix --- .../CLCascadeNavigationController/CLCascadeView.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Cascade/CLCascadeNavigationController/CLCascadeView.m b/src/Cascade/CLCascadeNavigationController/CLCascadeView.m index a516030..a6d6ca0 100644 --- a/src/Cascade/CLCascadeNavigationController/CLCascadeView.m +++ b/src/Cascade/CLCascadeNavigationController/CLCascadeView.m @@ -344,9 +344,12 @@ -(void)layoutSubviews [ self->_pages enumerateObjectsUsingBlock: ^void(id obj_, NSUInteger idx_, BOOL *stop_) { - UIView* page_view_ = ( UIView* )obj_; - [ page_view_ setNeedsLayout ]; - + if (obj_ != [NSNull null]) + { + UIView* page_view_ = ( UIView* )obj_; + [ page_view_ setNeedsLayout ]; + } + *stop_ = NO; } ]; From 1bf80cdba987144f79179ac214ce6a369d7096f0 Mon Sep 17 00:00:00 2001 From: dodikk Date: Tue, 28 Feb 2012 11:48:34 +0200 Subject: [PATCH 10/17] ignoring svn repos --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 60d6791..aea2148 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ build Breakpoints.xcbkptlist Cascade.xcscheme CLCascade.xcscheme -xcschememanagement.plist \ No newline at end of file +xcschememanagement.plist +.svn From a8ac953c7f0396f29f7bb184313b2b8afe079621 Mon Sep 17 00:00:00 2001 From: dodikk Date: Tue, 28 Feb 2012 11:51:59 +0200 Subject: [PATCH 11/17] Publicised some methods. Code style fixes --- .../CLCascadeNavigationController.h | 3 + .../CLCascadeNavigationController.m | 7 ++- .../CLCascadeView.m | 58 ++++++++++--------- 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.h b/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.h index a4c1564..34cb05e 100644 --- a/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.h +++ b/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.h @@ -20,6 +20,8 @@ CLCascadeView* _cascadeView; } +@property (nonatomic, strong, readonly) CLCascadeView* cascadeView; + /* List of CLViewControllers on stock. */ @@ -45,6 +47,7 @@ * If sender is not last, then controller pop next controller and push new view from sender */ - (void) addViewController:(CLViewController*)viewController sender:(CLViewController*)sender animated:(BOOL)animated; +- (void) popPagesFromLastIndexTo:(NSInteger)toIndex; /* First in hierarchy CascadeViewController (opposite to lastCascadeViewController) diff --git a/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m b/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m index 6438f27..efb3c47 100644 --- a/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m +++ b/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m @@ -40,6 +40,11 @@ - (void)didReceiveMemoryWarning #pragma mark - View lifecycle +- (CLCascadeView*)cascadeView +{ + return _cascadeView; +} + - (void)viewDidLoad { [super viewDidLoad]; @@ -221,7 +226,7 @@ - (void) cascadeView:(CLCascadeView*)cascadeView pageDidDisappearAtIndex:(NSInte if (index > [_viewControllers count] - 1) return; UIViewController* controller = [_viewControllers objectAtIndex: index]; - if ([controller respondsToSelector:@selector(pageDidAppear)]) { + if ([controller respondsToSelector:@selector(pageDidDisappear)]) { [controller pageDidDisappear]; } diff --git a/src/Cascade/CLCascadeNavigationController/CLCascadeView.m b/src/Cascade/CLCascadeNavigationController/CLCascadeView.m index a6d6ca0..1fe1438 100644 --- a/src/Cascade/CLCascadeNavigationController/CLCascadeView.m +++ b/src/Cascade/CLCascadeNavigationController/CLCascadeView.m @@ -1,4 +1,4 @@ -// + // // CLCascadeView.m // Cascade // @@ -39,7 +39,7 @@ - (CGPoint) calculateOriginOfPageAtIndex:(NSInteger)index; - (void) setProperContentSize; - (void) setProperEdgeInset:(BOOL)animated; - (void) setProperEdgeInset:(BOOL)animated forInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation; -- (void) setProperSizesForLodedPages:(UIInterfaceOrientation)interfaceOrientation; +- (void) setProperSizesForLoadedPages:(UIInterfaceOrientation)interfaceOrientation; - (void) unloadPage:(UIView*)page remove:(BOOL)remove; - (void) loadBoundaryPagesIfNeeded; @@ -247,6 +247,7 @@ - (void) popAllPagesAnimated:(BOOL)animated { - (UIView*) loadPageAtIndex:(NSInteger)index { // check if index exist if ([self pageExistAtIndex: index]) { + NSLog(@"[CLCascade view loadPageAtIndex] index: %d %d", index, [self pageExistAtIndex: index] ); id item = [_pages objectAtIndex:index]; // if item at index is null @@ -334,7 +335,7 @@ -(void)layoutSubviews // recalculate pages height and width - [ self setProperSizesForLodedPages: interfaceOrientation ]; + [ self setProperSizesForLoadedPages: interfaceOrientation ]; //dodikk - crash workaround if ( [ self->_pages isEqual: [ NSNull null ] ] ) @@ -364,7 +365,7 @@ - (void)updateContentLayoutToInterfaceOrientation:(UIInterfaceOrientation)interf forInterfaceOrientation: interfaceOrientation ]; // recalculate pages height and width - [ self setProperSizesForLodedPages: interfaceOrientation ]; + [ self setProperSizesForLoadedPages: interfaceOrientation ]; } @@ -593,16 +594,17 @@ - (void) setProperEdgeInset:(BOOL)animated forInterfaceOrientation:(UIInterfaceO /////////////////////////////////////////////////////////////////////////////////////////////////// - (UIEdgeInsets) calculateEdgeInset:(UIInterfaceOrientation)interfaceOrientation { - CGFloat leftInset = CATEGORIES_VIEW_WIDTH - _leftInset; - CGFloat rightInset = 0.0f; + CGFloat leftInset = CATEGORIES_VIEW_WIDTH - _leftInset; + CGFloat rightInset = 0.0f; //left inset depends on interface orientation - if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) { - rightInset = 2 * _pageWidth + _leftInset - self.bounds.size.width; - } + if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) + { + rightInset = 2 * _pageWidth + _leftInset - self.bounds.size.width; + } - // return edge inset - return UIEdgeInsetsMake(0.0f, leftInset, 0.0f, rightInset); + // return edge inset + return UIEdgeInsetsMake(0.0f, leftInset, 0.0f, rightInset); } @@ -671,7 +673,7 @@ - (CGSize) calculatePageSize:(UIView*)view { /////////////////////////////////////////////////////////////////////////////////////////////////// --(void)setProperSizesForLodedPages:(UIInterfaceOrientation)interfaceOrientation +-(void)setProperSizesForLoadedPages:(UIInterfaceOrientation)interfaceOrientation { [ _pages enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { @@ -740,11 +742,14 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView { if ((firstVisiblePageIndex == 0) && (-_scrollView.contentOffset.x >= _scrollView.contentInset.left)) { // get page at index id item = [_pages objectAtIndex: firstVisiblePageIndex]; - UIView* view = (UIView*)item; + if( item != [ NSNull null ] ) + { + UIView* view = (UIView*)item; - CGRect rect = [view frame]; - rect.origin.x = 0; - [view setFrame: rect]; + CGRect rect = [view frame]; + rect.origin.x = 0; + [view setFrame: rect]; + } } [self loadBoundaryPagesIfNeeded]; @@ -756,7 +761,10 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView { if ([self pageExistAtIndex: i]) { // get page at index id item = [_pages objectAtIndex: i]; - + if( item == [ NSNull null ] ) + { + break; + } if (i == firstVisiblePageIndex) { // if (item == [NSNull null]) { @@ -768,18 +776,15 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView { if (((i == 0) && (contentOffset <= 0)) || ([_pages count] == 1)) { return; } - - UIView* view = (UIView*)item; + UIView* view = (UIView*)item; - CGRect rect = [view frame]; - rect.origin.x = contentOffset; - [view setFrame: rect]; + CGRect rect = [view frame]; + rect.origin.x = contentOffset; + [view setFrame: rect]; } else { - if (item != [NSNull null]) { [self unloadPage:item remove:NO]; - } - + } } } @@ -822,7 +827,8 @@ - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView { /////////////////////////////////////////////////////////////////////////////////////////////////// - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { if (_flags.isDetachPages) _flags.isDetachPages = NO; - [_scrollView setPagingEnabled: NO]; + //apuz - Freezing cascade view bug fix(I hope). + //[_scrollView setPagingEnabled: NO]; } From 10ad8f9c0b1ffbdbd28f2bf2730d93499b4cea00 Mon Sep 17 00:00:00 2001 From: dodikk Date: Tue, 28 Feb 2012 11:52:19 +0200 Subject: [PATCH 12/17] Remonde obsolete "find" product --- src/Cascade/files.txt | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 src/Cascade/files.txt diff --git a/src/Cascade/files.txt b/src/Cascade/files.txt deleted file mode 100644 index e45c467..0000000 --- a/src/Cascade/files.txt +++ /dev/null @@ -1,16 +0,0 @@ -./Cascade.h -./CLCascadeNavigationController/CLCascadeNavigationController.h -./CLCascadeNavigationController/CLCascadeView.h -./CLCategories/CLCategoriesView.h -./CLCategories/CLCategoriesViewController.h -./CLCustomViewControllers/CLTableViewController.h -./CLCustomViewControllers/CLViewController.h -./CLCustomViewControllers/CLViewControllerDelegate.h -./CLCustomViewControllers/CLWebViewController.h -./CLSplitViewController/CLSplitCascadeView.h -./CLSplitViewController/CLSplitCascadeViewController.h -./Other/CLBorderShadowView.h -./Other/CLGlobal.h -./Other/CLScrollView.h -./Other/CLSegmentedView.h -./Other/UIViewController+CLSegmentedView.h From c88c9b6a441cced56f8b55e9ede6c4003e8c6f03 Mon Sep 17 00:00:00 2001 From: dodikk Date: Tue, 28 Feb 2012 11:57:37 +0200 Subject: [PATCH 13/17] dodikk - checking the range --- .../CLCascadeView.m | 65 ++++++++++++++----- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/src/Cascade/CLCascadeNavigationController/CLCascadeView.m b/src/Cascade/CLCascadeNavigationController/CLCascadeView.m index 1fe1438..d288a8f 100644 --- a/src/Cascade/CLCascadeNavigationController/CLCascadeView.m +++ b/src/Cascade/CLCascadeNavigationController/CLCascadeView.m @@ -191,29 +191,59 @@ - (void) pushPage:(UIView*)newPage fromPage:(UIView*)fromPage animated:(BOOL)ani /////////////////////////////////////////////////////////////////////////////////////////////////// -- (void) popPageAtIndex:(NSInteger)index animated:(BOOL)animated { - // get item at index - __unsafe_unretained id item = [_pages objectAtIndex:index]; + +-(NSInteger)normalizeIndex:(NSInteger)index +{ + NSUInteger pages_count_ = [ _pages count ]; + + if ( index >= pages_count_ ) + { + index = pages_count_ - 1; + } + else if ( index < 0 ) + { + index = 0; + } + + return index; +} + +- (void) popPageAtIndex:(NSInteger)index + animated:(BOOL)animated +{ + NSUInteger pages_count_ = [ _pages count ]; + if ( 0 == pages_count_ ) + { + return; + } + index = [ self normalizeIndex: index ]; + __unsafe_unretained id item = [_pages objectAtIndex:index]; // check if page is unloaded - if (item != [NSNull null]) { + if (item != [NSNull null]) + { - if (animated) { + if (animated) + { // animate pop [UIView animateWithDuration:0.4f - animations:^ { - [item setAlpha: 0.0f]; - } - completion:^(BOOL finished) { - // unload and remove page - [self unloadPage:item remove:YES]; - // update edge inset - [self setProperEdgeInset: NO]; - // send delegate message - [self didPopPageAtIndex: index]; - }]; + animations:^ + { + [item setAlpha: 0.0f]; + } + completion:^(BOOL finished) + { + // unload and remove page + [self unloadPage:item remove:YES]; + // update edge inset + [self setProperEdgeInset: NO]; + // send delegate message + [self didPopPageAtIndex: index]; + }]; - } else { + } + else + { // unload and remove page [self unloadPage:item remove:YES]; // update edge inset @@ -222,7 +252,6 @@ - (void) popPageAtIndex:(NSInteger)index animated:(BOOL)animated { [self didPopPageAtIndex: index]; } } - } From b07eab3bfb522ea2eaa28082f56d0d945cc4e74c Mon Sep 17 00:00:00 2001 From: dodikk Date: Tue, 28 Feb 2012 11:58:12 +0200 Subject: [PATCH 14/17] renamed a method --- src/Cascade/CLCascadeNavigationController/CLCascadeView.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cascade/CLCascadeNavigationController/CLCascadeView.m b/src/Cascade/CLCascadeNavigationController/CLCascadeView.m index d288a8f..1c37590 100644 --- a/src/Cascade/CLCascadeNavigationController/CLCascadeView.m +++ b/src/Cascade/CLCascadeNavigationController/CLCascadeView.m @@ -192,7 +192,7 @@ - (void) pushPage:(UIView*)newPage fromPage:(UIView*)fromPage animated:(BOOL)ani /////////////////////////////////////////////////////////////////////////////////////////////////// --(NSInteger)normalizeIndex:(NSInteger)index +-(NSInteger)normalizePageIndex:(NSInteger)index { NSUInteger pages_count_ = [ _pages count ]; @@ -216,7 +216,7 @@ - (void) popPageAtIndex:(NSInteger)index { return; } - index = [ self normalizeIndex: index ]; + index = [ self normalizePageIndex: index ]; __unsafe_unretained id item = [_pages objectAtIndex:index]; // check if page is unloaded From 695ba024e3788b5d65eeadf398cd5d0ca8468bd5 Mon Sep 17 00:00:00 2001 From: dodikk Date: Tue, 28 Feb 2012 14:21:50 +0200 Subject: [PATCH 15/17] Added logging and overflow checks --- .../CLCascadeNavigationController.m | 119 ++++++++++++------ .../CLCascadeView.h | 4 +- .../CLCascadeView.m | 22 +++- 3 files changed, 103 insertions(+), 42 deletions(-) diff --git a/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m b/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m index efb3c47..a906022 100644 --- a/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m +++ b/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m @@ -11,6 +11,9 @@ #import "CLViewController.h" #import "CLSegmentedView.h" +#define NSDebugLog( ... ) NSLog( __VA_ARGS__ ) +//#define NSDebugLog( ... ) + @interface CLCascadeNavigationController (Private) - (void) addPagesRoundedCorners; - (void) addRoundedCorner:(UIRectCorner)rectCorner toPageAtIndex:(NSInteger)index; @@ -281,39 +284,63 @@ - (void) setRootViewController:(CLViewController*)viewController animated:(BOOL) } /////////////////////////////////////////////////////////////////////////////////////////////////// -- (void) addViewController:(CLViewController*)viewController sender:(CLViewController*)sender animated:(BOOL)animated { - - // if in not sent from categoirs view - if (sender) { - - // get index of sender - NSInteger indexOfSender = [_viewControllers indexOfObject:sender]; - - // if sender is not last view controller - if (indexOfSender != [_viewControllers count] - 1) { - - // pop views and remove from _viewControllers - [self popPagesFromLastIndexTo:indexOfSender]; - } - } - - // set cascade navigator to view controller - [viewController setCascadeNavigationController: self]; - // add controller to array - [self.viewControllers addObject: viewController]; - - #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0 - [self addChildViewController:viewController]; - #endif - - // push view - [_cascadeView pushPage:[viewController view] - fromPage:[sender view] - animated:animated]; - - #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0 - [viewController didMoveToParentViewController:self]; - #endif +-(void)addViewController:(CLViewController*)viewController + sender:(CLViewController*)sender + animated:(BOOL)animated +{ + // if in not sent from categoirs view + if (sender) + { + // get index of sender + NSInteger indexOfSender = [_viewControllers indexOfObject:sender]; + + // if sender is not last view controller + if (indexOfSender != [_viewControllers count] - 1) + { + // pop views and remove from _viewControllers + [self popPagesFromLastIndexTo:indexOfSender]; + } + } + + UIView* sender_view_ = [ sender view ]; + UIView* view_to_push_ = [ viewController view ]; + + NSDebugLog + ( + @"CLCascadeNavigationController->addViewController: %@" + @"\n \t\t\t " @"sender: %@" + @"\n \t\t\t " @"animated: %d" + @"\n" + @"\n \t\t\t " @"self->_cascadeView: %@" + @"\n \t\t\t " @"sender->view: %@" + @"\n \t\t\t " @"viewController->view: %@" + , viewController + , sender + , animated + , _cascadeView + , sender_view_ + , view_to_push_ + ); + + // set cascade navigator to view controller + [viewController setCascadeNavigationController: self]; + // add controller to array + [self.viewControllers addObject: viewController]; + + { +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0 + [self addChildViewController:viewController]; +#endif + + // push view + [ _cascadeView pushPage: view_to_push_ + fromPage: sender_view_ + animated: animated ]; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0 + [viewController didMoveToParentViewController:self]; +#endif + } } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -387,16 +414,32 @@ - (void) addPagesRoundedCorners { /////////////////////////////////////////////////////////////////////////////////////////////////// -- (void) popPagesFromLastIndexTo:(NSInteger)toIndex { - if (toIndex < 0) toIndex = 0; +-(void)popPagesFromLastIndexTo:(NSInteger)toIndex +{ + NSUInteger view_controllers_count_ = [_viewControllers count]; + if ( 0 == view_controllers_count_ ) + { + return; + } + + if (toIndex < 0) + { + toIndex = 0; + } // index of last page - NSUInteger index = [_viewControllers count] - 1; + NSUInteger index = view_controllers_count_ - 1; // pop page from back NSEnumerator* enumerator = [_viewControllers reverseObjectEnumerator]; // enumarate pages - while ([enumerator nextObject] && _viewControllers.count > toIndex+1) { - + while ([enumerator nextObject] && _viewControllers.count > toIndex+1) + { + if ( ![ _cascadeView canPopPageAtIndex: index ] ) + { + //dodikk - maybe break fits better + continue; + } + #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0 UIViewController* viewController = [_viewControllers objectAtIndex:index]; [viewController willMoveToParentViewController:nil]; diff --git a/src/Cascade/CLCascadeNavigationController/CLCascadeView.h b/src/Cascade/CLCascadeNavigationController/CLCascadeView.h index bb5acdf..fa91987 100644 --- a/src/Cascade/CLCascadeNavigationController/CLCascadeView.h +++ b/src/Cascade/CLCascadeNavigationController/CLCascadeView.h @@ -63,7 +63,9 @@ - (void) pushPage:(UIView*)newPage fromPage:(UIView*)fromPage animated:(BOOL)animated; -- (void) popPageAtIndex:(NSInteger)index animated:(BOOL)animated; +-(void)popPageAtIndex:(NSInteger)index animated:(BOOL)animated; +-(BOOL)canPopPageAtIndex:(NSInteger)index; + - (void) popAllPagesAnimated:(BOOL)animated; - (UIView*) loadPageAtIndex:(NSInteger)index; diff --git a/src/Cascade/CLCascadeNavigationController/CLCascadeView.m b/src/Cascade/CLCascadeNavigationController/CLCascadeView.m index 1c37590..03fe926 100644 --- a/src/Cascade/CLCascadeNavigationController/CLCascadeView.m +++ b/src/Cascade/CLCascadeNavigationController/CLCascadeView.m @@ -192,6 +192,14 @@ - (void) pushPage:(UIView*)newPage fromPage:(UIView*)fromPage animated:(BOOL)ani /////////////////////////////////////////////////////////////////////////////////////////////////// +-(BOOL)canPopPageAtIndex:(NSInteger)index +{ + NSRange pages_range_ = { 0, [ _pages count ] }; + BOOL result_ = NSLocationInRange( index, pages_range_ ); + + return result_; +} + -(NSInteger)normalizePageIndex:(NSInteger)index { NSUInteger pages_count_ = [ _pages count ]; @@ -208,8 +216,8 @@ -(NSInteger)normalizePageIndex:(NSInteger)index return index; } -- (void) popPageAtIndex:(NSInteger)index - animated:(BOOL)animated +-(void)popPageAtIndex:(NSInteger)index + animated:(BOOL)animated { NSUInteger pages_count_ = [ _pages count ]; if ( 0 == pages_count_ ) @@ -252,6 +260,8 @@ - (void) popPageAtIndex:(NSInteger)index [self didPopPageAtIndex: index]; } } + + } @@ -997,11 +1007,17 @@ - (void) sendDetachDelegateMethodsIfNeeded { #pragma mark Setters /////////////////////////////////////////////////////////////////////////////////////////////////// -- (void) setLeftInset:(CGFloat)newLeftInset { +- (void) setLeftInset:(CGFloat)newLeftInset +{ CGFloat width = [UIScreen mainScreen].bounds.size.height; _leftInset = newLeftInset; _pageWidth = (width - _leftInset) / 2.0f; + + if ( 0.f == _pageWidth ) + { + NSAssert( NO, @"CLCascadeView->_pageWidth == 0. Possible zero division crashes" ); + } _scrollView.frame = CGRectMake(_leftInset, 0.0, _pageWidth, self.frame.size.height); From 7399bf014e549fffaabff3a44b5cdf0d82c72680 Mon Sep 17 00:00:00 2001 From: dodikk Date: Tue, 28 Feb 2012 14:24:26 +0200 Subject: [PATCH 16/17] set deployment version to iOS 5 in order to enable "willMoveToParentViewController/removeFromParentViewController" features --- src/Cascade/Cascade.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cascade/Cascade.xcodeproj/project.pbxproj b/src/Cascade/Cascade.xcodeproj/project.pbxproj index cef66d1..98a69e2 100644 --- a/src/Cascade/Cascade.xcodeproj/project.pbxproj +++ b/src/Cascade/Cascade.xcodeproj/project.pbxproj @@ -447,7 +447,7 @@ "./**", .., ); - IPHONEOS_DEPLOYMENT_TARGET = 4.0; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; SDKROOT = iphoneos; }; name = Debug; @@ -468,7 +468,7 @@ "./**", .., ); - IPHONEOS_DEPLOYMENT_TARGET = 4.0; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; From b4f6bb99e038f0f9cf5ca5e3218c73073d30e8e8 Mon Sep 17 00:00:00 2001 From: dodikk Date: Tue, 28 Feb 2012 14:46:04 +0200 Subject: [PATCH 17/17] disabled debug logs --- .../CLCascadeNavigationController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m b/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m index a906022..2afcab2 100644 --- a/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m +++ b/src/Cascade/CLCascadeNavigationController/CLCascadeNavigationController.m @@ -11,8 +11,8 @@ #import "CLViewController.h" #import "CLSegmentedView.h" -#define NSDebugLog( ... ) NSLog( __VA_ARGS__ ) -//#define NSDebugLog( ... ) +//#define NSDebugLog( ... ) NSLog( __VA_ARGS__ ) +#define NSDebugLog( ... ) @interface CLCascadeNavigationController (Private) - (void) addPagesRoundedCorners;