- Some cleanup

- Structured menu for a better presentation of slide menu features
This commit is contained in:
Aryan Ghassemi 2014-01-26 15:27:57 -08:00
parent 93b7afcfd8
commit f1025d7792
4 changed files with 122 additions and 94 deletions

View File

@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
#import "SlideNavigationController.h"
@interface MenuViewController : UIViewController <UITableViewDelegate>
@interface MenuViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) NSString *cellIdentifier;

View File

@ -18,56 +18,74 @@
#pragma mark - UITableView Delegate & Datasrouce -
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
return (section == 0) ? 4 : 6;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return (section == 0) ? @"Navigation" : @"Menu Animation";
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:self.cellIdentifier];
switch (indexPath.row)
if (indexPath.section == 0)
{
case 0:
cell.textLabel.text = @"Home";
break;
case 1:
cell.textLabel.text = @"Profile";
break;
case 2:
cell.textLabel.text = @"Friends";
break;
case 3:
cell.textLabel.text = @"Sign Out";
break;
case 4:
cell.textLabel.text = @"No Animation";
break;
case 5:
cell.textLabel.text = @"Slide Animation";
break;
case 6:
cell.textLabel.text = @"Fade Animation";
break;
case 7:
cell.textLabel.text = @"Slide And Fade Animation";
break;
case 8:
cell.textLabel.text = @"Scale Animation";
break;
case 9:
cell.textLabel.text = @"Scale And Fade Animation";
break;
switch (indexPath.row)
{
case 0:
cell.textLabel.text = @"Home";
break;
case 1:
cell.textLabel.text = @"Profile";
break;
case 2:
cell.textLabel.text = @"Friends";
break;
case 3:
cell.textLabel.text = @"Sign Out";
break;
}
}
else
{
switch (indexPath.row)
{
case 0:
cell.textLabel.text = @"No Animation";
break;
case 1:
cell.textLabel.text = @"Slide Animation";
break;
case 2:
cell.textLabel.text = @"Fade Animation";
break;
case 3:
cell.textLabel.text = @"Slide And Fade Animation";
break;
case 4:
cell.textLabel.text = @"Scale Animation";
break;
case 5:
cell.textLabel.text = @"Scale And Fade Animation";
break;
}
}
return cell;
@ -78,62 +96,70 @@
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
bundle: nil];
UIViewController *vc ;
id <SlideNavigationContorllerAnimator> revealAnimator;
switch (indexPath.row)
if (indexPath.section == 0)
{
case 0:
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"HomeViewController"];
break;
case 1:
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"ProfileViewController"];
break;
case 2:
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"FriendsViewController"];
break;
case 3:
[[SlideNavigationController sharedInstance] popToRootViewControllerAnimated:YES];
return;
break;
case 4:
revealAnimator = nil;
break;
case 5:
revealAnimator = [[SlideNavigationContorllerAnimatorSlide alloc] init];
break;
case 6:
revealAnimator = [[SlideNavigationContorllerAnimatorFade alloc] init];
break;
case 7:
revealAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] init];
break;
case 8:
revealAnimator = [[SlideNavigationContorllerAnimatorScale alloc] init];
break;
case 9:
revealAnimator = [[SlideNavigationContorllerAnimatorScaleAndFade alloc] init];
break;
default:
return;
}
if (vc)
UIViewController *vc ;
switch (indexPath.row)
{
case 0:
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"HomeViewController"];
break;
case 1:
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"ProfileViewController"];
break;
case 2:
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"FriendsViewController"];
break;
case 3:
[[SlideNavigationController sharedInstance] popToRootViewControllerAnimated:YES];
return;
break;
}
[[SlideNavigationController sharedInstance] switchToViewController:vc withCompletion:nil];
}
else
{
id <SlideNavigationContorllerAnimator> revealAnimator;
switch (indexPath.row)
{
case 0:
revealAnimator = nil;
break;
case 1:
revealAnimator = [[SlideNavigationContorllerAnimatorSlide alloc] init];
break;
case 2:
revealAnimator = [[SlideNavigationContorllerAnimatorFade alloc] init];
break;
case 3:
revealAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] initWithMaximumFadeAlpha:.7 fadeColor:[UIColor purpleColor] andSlideMovement:100];
break;
case 4:
revealAnimator = [[SlideNavigationContorllerAnimatorScale alloc] init];
break;
case 5:
revealAnimator = [[SlideNavigationContorllerAnimatorScaleAndFade alloc] initWithMaximumFadeAlpha:.6 fadeColor:[UIColor blueColor] andMinimumScale:.7];
break;
default:
return;
}
[[SlideNavigationController sharedInstance] closeMenuWithCompletion:^{
[SlideNavigationController sharedInstance].menuRevealAnimator = revealAnimator;
}];
}
}
@end

View File

@ -11,5 +11,6 @@
@interface SlideNavigationContorllerAnimatorScaleAndFade : NSObject <SlideNavigationContorllerAnimator>
- (id)initWithMaximumFadeAlpha:(CGFloat)maximumFadeAlpha fadeColor:(UIColor *)fadeColor andMinimumScale:(CGFloat)minimumScale;
@end

View File

@ -14,9 +14,10 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="T7T-Ke-Ksy">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES"/>
<rect key="frame" x="0.0" y="20" width="320" height="548"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<inset key="insetFor6xAndEarlier" minX="0.0" minY="20" maxX="0.0" maxY="0.0"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="rightMenuCell" textLabel="69X-Zn-twq" style="IBUITableViewCellStyleDefault" id="Pb7-aS-2IS">
<rect key="frame" x="0.0" y="22" width="320" height="44"/>