Skip to content

Commit

Permalink
- deprecated unfoldLeftView, unfoldRightView & restoreToCenter. Repla…
Browse files Browse the repository at this point in the history
…ced with setPaperFoldState:

- updated README with new methods
  • Loading branch information
honcheng committed Aug 5, 2012
1 parent 3e6e89e commit fb97073
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
6 changes: 3 additions & 3 deletions PaperFold/PaperFold/DemoRootViewController.m
Expand Up @@ -105,17 +105,17 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
if (indexPath.row==0)
{
// unfold left view
[self unfoldLeftView];
[self setPaperFoldState:PaperFoldStateLeftUnfolded];
}
else if (indexPath.row==1)
{
// unfold right view
[self unfoldRightView];
[self setPaperFoldState:PaperFoldStateRightUnfolded];
}
else if (indexPath.row==2)
{
// restore to center
[self restoreToCenter];
[self setPaperFoldState:PaperFoldStateDefault];
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
Expand Down
11 changes: 7 additions & 4 deletions PaperFold/PaperFold/PaperFold/PaperFoldViewController.h
Expand Up @@ -76,9 +76,12 @@ typedef enum
- (void)setLeftFoldContentView:(UIView*)view;

// unfold the left and right view
- (void)unfoldLeftView;
- (void)unfoldRightView;
// restore to center
- (void)restoreToCenter;
- (void)setPaperFoldState:(PaperFoldState)state;

// deprecate methods
// use setPaperFoldState: instead
- (void)unfoldLeftView __attribute__((deprecated));
- (void)unfoldRightView __attribute__((deprecated));
- (void)restoreToCenter __attribute__((deprecated));

@end
22 changes: 19 additions & 3 deletions PaperFold/PaperFold/PaperFold/PaperFoldViewController.m
Expand Up @@ -261,19 +261,35 @@ - (void)restoreView:(NSTimer*)timer
}
}

- (void)setPaperFoldState:(PaperFoldState)state
{
if (state==PaperFoldStateDefault)
{
self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(restoreView:) userInfo:nil repeats:YES];
}
else if (state==PaperFoldStateLeftUnfolded)
{
self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(unfoldLeftView:) userInfo:nil repeats:YES];
}
else if (state==PaperFoldStateRightUnfolded)
{
self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(unfoldRightView:) userInfo:nil repeats:YES];
}
}

- (void)unfoldLeftView
{
self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(unfoldLeftView:) userInfo:nil repeats:YES];
[self setPaperFoldState:PaperFoldStateLeftUnfolded];
}

- (void)unfoldRightView
{
self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(unfoldRightView:) userInfo:nil repeats:YES];
[self setPaperFoldState:PaperFoldStateRightUnfolded];
}

- (void)restoreToCenter
{
self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(restoreView:) userInfo:nil repeats:YES];
[self setPaperFoldState:PaperFoldStateDefault];
}

- (void)didReceiveMemoryWarning
Expand Down
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -49,15 +49,15 @@ Usage

5) To unfold left view without dragging

[self unfoldLeftView];
[self setPaperFoldState:PaperFoldStateLeftUnfolded];

6) To unfold right view without dragging

[self unfoldRightView];
[self setPaperFoldState:PaperFoldStateRightUnfolded];

7) To restore view to center without dragging

[self restoreToCenter];
[self setPaperFoldState:PaperFoldStateDefault];

ARC
---
Expand Down

0 comments on commit fb97073

Please sign in to comment.