Skip to content

Commit

Permalink
fixed issue/pull request #91:
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanoa committed Sep 15, 2013
1 parent 11e9657 commit 0d40deb
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 81 deletions.
11 changes: 4 additions & 7 deletions SASlideMenu/ExampleDynamicMenuViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,15 @@ -(NSString*) segueIdForIndexPath:(NSIndexPath *)indexPath{
}

-(Boolean) slideOutThenIn{
return NO;
return YES;
}
//Disable caching for the controller at the first row of each section
-(Boolean) disableContentViewControllerCachingForIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row ==0) {
return YES;
}
return NO;
return YES;
}

//Enable the right menu for the the view controller in the first section
-(Boolean) hasRightMenuForIndexPath:(NSIndexPath *)indexPath{

return YES;
}

Expand Down Expand Up @@ -183,7 +179,7 @@ -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
#pragma mark -
#pragma mark SASlideMenuDelegate

/*
-(void) slideMenuWillSlideIn:(UINavigationController *)selectedContent{
NSLog(@"slideMenuWillSlideIn");
}
Expand All @@ -208,4 +204,5 @@ -(void) slideMenuWillSlideToLeft:(UINavigationController *)selectedContent{
-(void) slideMenuDidSlideToLeft:(UINavigationController *)selectedContent{
NSLog(@"slideMenuDidSlideToLeft");
}
*/
@end
43 changes: 22 additions & 21 deletions SASlideMenu/SASlideMenu/SASlideMenuContentSegue.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,29 @@ -(void) perform{
layer.shadowPath =[UIBezierPath bezierPathWithRect:layer.bounds].CGPath;
}

[rootController switchToContentViewController:destination];

if ([rootController.leftMenu.slideMenuDataSource respondsToSelector:@selector(segueIdForIndexPath:)]) {
[rootController addContentViewController:destination withIndexPath:selectedIndexPath];
}
[rootController switchToContentViewController:destination completion:^{
if ([rootController.leftMenu.slideMenuDataSource respondsToSelector:@selector(segueIdForIndexPath:)]) {
[rootController addContentViewController:destination withIndexPath:selectedIndexPath];
}

//We do that after switchToContentViewController.
//because we need destination.parentViewController to be initialized.
if (hasRightMenu) {
[destination performSegueWithIdentifier:@"rightMenu" sender:rootController];
}

Boolean disablePanGesture= NO;
if ([rootController.leftMenu.slideMenuDataSource respondsToSelector:@selector(disablePanGestureForIndexPath:)]) {
disablePanGesture = [rootController.leftMenu.slideMenuDataSource disablePanGestureForIndexPath:selectedIndexPath];
}
if (!disablePanGesture) {
UIPanGestureRecognizer* panGesture= [[UIPanGestureRecognizer alloc] initWithTarget:rootController action:@selector(panItem:)];
[panGesture setMaximumNumberOfTouches:2];
[panGesture setDelegate:source];
[destination.view addGestureRecognizer:panGesture];
}
}];

//We do that after switchToContentViewController.
//because we need destination.parentViewController to be initialized.
if (hasRightMenu) {
[destination performSegueWithIdentifier:@"rightMenu" sender:rootController];
}

Boolean disablePanGesture= NO;
if ([rootController.leftMenu.slideMenuDataSource respondsToSelector:@selector(disablePanGestureForIndexPath:)]) {
disablePanGesture = [rootController.leftMenu.slideMenuDataSource disablePanGestureForIndexPath:selectedIndexPath];
}
if (!disablePanGesture) {
UIPanGestureRecognizer* panGesture= [[UIPanGestureRecognizer alloc] initWithTarget:rootController action:@selector(panItem:)];
[panGesture setMaximumNumberOfTouches:2];
[panGesture setDelegate:source];
[destination.view addGestureRecognizer:panGesture];
}
}

@end
2 changes: 1 addition & 1 deletion SASlideMenu/SASlideMenu/SASlideMenuRootViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@property (nonatomic,assign) Boolean isRightMenuEnabled;
@property (nonatomic,strong) SASlideMenuNavigationController* navigationController;

-(void) switchToContentViewController:(UINavigationController*) content;
-(void) switchToContentViewController:(UINavigationController*) content completion:(void (^)(void))completion;
-(void) addContentViewController:(UIViewController*) content withIndexPath:(NSIndexPath*)indexPath;

-(void) popRightNavigationController;
Expand Down
15 changes: 12 additions & 3 deletions SASlideMenu/SASlideMenu/SASlideMenuRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ -(void) tapShield:(UITapGestureRecognizer*)gesture{
[self doSlideIn:nil];
}
-(void) tapItem:(UITapGestureRecognizer*)gesture{
[self switchToContentViewController:self.selectedContent];
[self switchToContentViewController:self.selectedContent completion:nil];
}

-(void) panItem:(UIPanGestureRecognizer*)gesture{
Expand Down Expand Up @@ -340,7 +340,7 @@ -(UINavigationController*) controllerForIndexPath:(NSIndexPath*) indexPath{
return [controllers objectForKey:indexPath];
}

-(void) switchToContentViewController:(UINavigationController*) content{
-(void) switchToContentViewController:(UINavigationController*) content completion:(void (^)(void))completion{
CGRect bounds = self.view.bounds;
self.view.userInteractionEnabled = NO;
if ([self.leftMenu.slideMenuDataSource respondsToSelector:@selector(prepareForSwitchToContentViewController:)]) {
Expand All @@ -364,8 +364,12 @@ -(void) switchToContentViewController:(UINavigationController*) content{
[self addChildViewController:content];
[self.view addSubview:content.view];
self.selectedContent = content;
[NSThread sleepForTimeInterval:1.0];
[self doSlideIn:^(BOOL slideInCompleted) {
[content didMoveToParentViewController:self];
if(completion){
completion();
}
self.view.userInteractionEnabled = YES;
}];
}];
Expand All @@ -379,6 +383,9 @@ -(void) switchToContentViewController:(UINavigationController*) content{
self.selectedContent = content;
[self doSlideIn:^(BOOL completed) {
[content didMoveToParentViewController:self];
if(completion){
completion();
}
self.view.userInteractionEnabled = YES;
}];
}
Expand All @@ -405,8 +412,10 @@ -(void) switchToContentViewController:(UINavigationController*) content{
[self.leftMenu.slideMenuDelegate slideMenuDidSlideIn:self.selectedContent];
}
[content didMoveToParentViewController:self];
if(completion){
completion();
}
self.view.userInteractionEnabled = YES;

}
}

Expand Down
2 changes: 1 addition & 1 deletion SASlideMenu/SASlideMenu/SASlideMenuViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ - (void)loadContentAtIndexPath:(NSIndexPath*)indexPath {
if ([self.slideMenuDataSource respondsToSelector:@selector(segueIdForIndexPath:)]) {
UINavigationController* controller = [self.rootController controllerForIndexPath:indexPath];
if (controller) {
[self.rootController switchToContentViewController:controller];
[self.rootController switchToContentViewController:controller completion:nil];
return;
}
NSString* segueId = [self.slideMenuDataSource segueIdForIndexPath:indexPath];
Expand Down
48 changes: 0 additions & 48 deletions SASlideMenuDynamic/en.lproj/MainStoryboard.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -562,54 +562,6 @@
<image name="rowsquare.png" width="308" height="44"/>
<image name="selectedColoredRow.png" width="320" height="44"/>
</resources>
<classes>
<class className="ColoredDetailViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/ColoredDetailViewController.h"/>
<relationships>
<relationship kind="outlet" name="brightness" candidateClass="UILabel"/>
<relationship kind="outlet" name="colorBox" candidateClass="UIView"/>
<relationship kind="outlet" name="hue" candidateClass="UILabel"/>
<relationship kind="outlet" name="saturation" candidateClass="UILabel"/>
</relationships>
</class>
<class className="ColoredViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/ColoredViewController.h"/>
</class>
<class className="ExampleDynamicMenuViewController" superclassName="SASlideMenuViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/ExampleDynamicMenuViewController.h"/>
</class>
<class className="FirstViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/FirstViewController.h"/>
<relationships>
<relationship kind="action" name="tap:"/>
<relationship kind="outlet" name="tapGesture" candidateClass="UITapGestureRecognizer"/>
</relationships>
</class>
<class className="GreenViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/GreenViewController.h"/>
<relationships>
<relationship kind="action" name="tap:"/>
</relationships>
</class>
<class className="SASlideMenuNavigationController" superclassName="UINavigationController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/SASlideMenuNavigationController.h"/>
</class>
<class className="SASlideMenuRightMenuViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/SASlideMenuRightMenuViewController.h"/>
</class>
<class className="SASlideMenuRootViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/SASlideMenuRootViewController.h"/>
</class>
<class className="SASlideMenuViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/SASlideMenuViewController.h"/>
</class>
<class className="SecondViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/SecondViewController.h"/>
<relationships>
<relationship kind="action" name="tap:"/>
</relationships>
</class>
</classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
Expand Down

0 comments on commit 0d40deb

Please sign in to comment.