Skip to content

Commit

Permalink
Added on PDFViewController "next" and "previous" page button on navig…
Browse files Browse the repository at this point in the history
…ation bar
  • Loading branch information
Salvatore Ansani committed Aug 4, 2010
1 parent 29e6221 commit c7f0192
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 28 deletions.
23 changes: 23 additions & 0 deletions Classes/PDFExampleViewController.m
Expand Up @@ -121,12 +121,35 @@ - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx

}

#pragma mark Page Moving Commands

-(SEL)nextPage {
[self goToPage:leavesView.currentPageIndex+1];
[self displayPageNumber:leavesView.currentPageIndex+1];
}

-(SEL)previousPage {
[self goToPage:leavesView.currentPageIndex-1];
[self displayPageNumber:leavesView.currentPageIndex+1];
}


#pragma mark UIViewController

- (void) viewDidLoad {
[super viewDidLoad];
leavesView.backgroundRendering = YES;
[self displayPageNumber:1];


UIBarButtonItem *previousPageButton = [[UIBarButtonItem alloc] initWithTitle:@"<" style:UIBarButtonItemStylePlain target:self action:@selector(previousPage)];
UIBarButtonItem *nextPageButton = [[UIBarButtonItem alloc] initWithTitle:@">" style:UIBarButtonItemStylePlain target:self action:@selector(nextPage)];
self.navigationItem.leftBarButtonItem = previousPageButton;
self.navigationItem.rightBarButtonItem = nextPageButton;

[previousPageButton release];
[nextPageButton release];

}

@end
53 changes: 26 additions & 27 deletions Leaves.xcodeproj/dok.perspectivev3
Expand Up @@ -300,8 +300,8 @@
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
<integer>7</integer>
<integer>1</integer>
<integer>14</integer>
<integer>8</integer>
<integer>0</integer>
</array>
</array>
Expand Down Expand Up @@ -341,32 +341,33 @@
<key>PBXProjectModuleGUID</key>
<string>EAB43E2911FDDFC3003AF043</string>
<key>PBXProjectModuleLabel</key>
<string>LeavesViewController.m</string>
<string>PDFExampleViewController.m</string>
<key>PBXSplitModuleInNavigatorKey</key>
<dict>
<key>Split0</key>
<dict>
<key>PBXProjectModuleGUID</key>
<string>EAB43E2A11FDDFC3003AF043</string>
<key>PBXProjectModuleLabel</key>
<string>LeavesViewController.m</string>
<string>PDFExampleViewController.m</string>
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>EA9E4123120846F90074F341</string>
<string>EA0645FF1209B6B2003351B3</string>
<key>history</key>
<array>
<string>EA2A00D511FECE2500BDAABB</string>
<string>EAF23E6A11FEE09600AEC56D</string>
<string>EAF23E6B11FEE09600AEC56D</string>
<string>EA22780D120002B0005AE585</string>
<string>EAED07F21200138B0023AFB8</string>
<string>EAED0800120014590023AFB8</string>
<string>EA9E40FC120840D80074F341</string>
<string>EA9E411A120845EE0074F341</string>
<string>EA9E411B120845EE0074F341</string>
<string>EA9E411C120845EE0074F341</string>
<string>EA9E411D120845EE0074F341</string>
<string>EAB126461209616500BE9C6C</string>
<string>EAB126471209616500BE9C6C</string>
<string>EA06456F1209B1D4003351B3</string>
<string>EA0645E51209B611003351B3</string>
<string>EA0645F31209B67D003351B3</string>
<string>EA0645F41209B67D003351B3</string>
<string>EA0645FE1209B6AB003351B3</string>
</array>
</dict>
<key>SplitCount</key>
Expand All @@ -380,18 +381,18 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {1473, 623}}</string>
<string>{{0, 0}, {1473, 611}}</string>
<key>RubberWindowFrame</key>
<string>0 113 1680 915 0 0 1680 1028 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Proportion</key>
<string>623pt</string>
<string>611pt</string>
</dict>
<dict>
<key>Proportion</key>
<string>246pt</string>
<string>258pt</string>
<key>Tabs</key>
<array>
<dict>
Expand All @@ -405,7 +406,7 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{10, 27}, {1473, 219}}</string>
<string>{{10, 27}, {1473, 231}}</string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
Expand Down Expand Up @@ -459,7 +460,7 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{10, 27}, {1473, 219}}</string>
<string>{{10, 27}, {1473, 231}}</string>
<key>RubberWindowFrame</key>
<string>0 113 1680 915 0 0 1680 1028 </string>
</dict>
Expand Down Expand Up @@ -489,11 +490,11 @@
</array>
<key>TableOfContents</key>
<array>
<string>EA9E4107120841220074F341</string>
<string>EA06454C1209AECC003351B3</string>
<string>1CA23ED40692098700951B8B</string>
<string>EA9E4108120841220074F341</string>
<string>EA06454D1209AECC003351B3</string>
<string>EAB43E2911FDDFC3003AF043</string>
<string>EA9E4109120841220074F341</string>
<string>EA06454E1209AECC003351B3</string>
<string>1CA23EDF0692099D00951B8B</string>
<string>1CA23EE00692099D00951B8B</string>
<string>1CA23EE10692099D00951B8B</string>
Expand Down Expand Up @@ -642,13 +643,13 @@
</array>
<key>TableOfContents</key>
<array>
<string>EA9E410A120841220074F341</string>
<string>EA06454F1209AECC003351B3</string>
<string>1CCC7628064C1048000F2A68</string>
<string>1CCC7629064C1048000F2A68</string>
<string>EA9E410B120841220074F341</string>
<string>EA9E410C120841220074F341</string>
<string>EA9E410D120841220074F341</string>
<string>EA9E410E120841220074F341</string>
<string>EA0645501209AECC003351B3</string>
<string>EA0645511209AECC003351B3</string>
<string>EA0645521209AECC003351B3</string>
<string>EA0645531209AECC003351B3</string>
<string>EAB43E2911FDDFC3003AF043</string>
</array>
<key>ToolbarConfigUserDefaultsMinorVersion</key>
Expand All @@ -666,7 +667,7 @@
<key>StatusbarIsVisible</key>
<true/>
<key>TimeStamp</key>
<real>302532345.14434803</real>
<real>302626482.20534903</real>
<key>ToolbarConfigUserDefaultsMinorVersion</key>
<string>2</string>
<key>ToolbarDisplayMode</key>
Expand All @@ -683,8 +684,6 @@
<integer>5</integer>
<key>WindowOrderList</key>
<array>
<string>EA9E410F120841220074F341</string>
<string>EA9E4110120841220074F341</string>
<string>/Users/dok/Dropbox/xCode/SCM/leaves/Leaves.xcodeproj</string>
</array>
<key>WindowString</key>
Expand Down
2 changes: 1 addition & 1 deletion Leaves/LeavesViewController.m
Expand Up @@ -83,7 +83,7 @@ - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrie

- (void) goToPage:(NSInteger)pageNumber {
// Remember that currentPageIndex start from 0!
if ([self numberOfPagesInLeavesView:leavesView] > 0)
if (pageNumber >= 0 && pageNumber < [self numberOfPagesInLeavesView:leavesView])
leavesView.currentPageIndex = pageNumber;
}

Expand Down

0 comments on commit c7f0192

Please sign in to comment.