Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example describes some methods of working with regular report page selection view delegate. After starting the example the following operations are executed:
Regular report page selection view is retrieved.
Regular report page selection view delegate is retrieved.
Number of document pages is retrieved.
New current page is set.
Transition to the current page is executed.
Page selection view is reloaded.
Page thumbnail is retrieved by specified index by the <PageSelectorDelegate>.thumbnailByIndex: method.
Current page thumbnail is retrieved by the PdfPageSelector.selectedPageView method.
Executing the example requires to place the following code in the body of the executeExample method of the ViewController class (see the Displaying of Regular Report section):
// Get regular report object MAProceduralReportViewController *proceduralReportController = (MAProceduralReportViewController *)m_controller; // Get array of regular report views NSArray *dataViewControllers = [proceduralReportController dataViewControllers]; // Parse regular report views in cycle for( UIViewController *controller in dataViewControllers) { // Check if the current view is a regular report viewer if([controller isMemberOfClass:[MAProceduralReportDataViewController class]]) { // Get sheet viewer view MAProceduralReportDataViewController *dataViewController =(MAProceduralReportDataViewController *)controller; // Get regular report viewer view MAProceduralReportDataViewControllerBase *reportDataViewControllerBase = (MAProceduralReportDataViewControllerBase *)dataViewController; // Get sheet page selection view PdfPageSelector *pageSelector = [reportDataViewControllerBase pageSelector]; // Get page selection view delegate id<PageSelectorDelegate> pageSelectorDelegate = [pageSelector delegate]; // Check number of document pages if([pageSelector pagesCount] > 0) { // Set new page as the current one [pageSelector setCurrentPage:1]; // Display current page index in the development environment console NSLog(@"Current page index: %d", [pageSelector currentPage]); // Go to the current page [pageSelectorDelegate changePage:[pageSelector currentPage]]; } // Reload page selection view [pageSelector reloadData]; // Display current page index after view reload in the development environment console NSLog(@"Current page index after page selection view reload: %d", [pageSelector currentPage]); } }
After executing the example the mobile device screen displays the regular report, for which transition to the specified page is executed:
The development environment console also displays a message containing current page index after setting index value, and also a message with current page index after reloading the page selection view:
Current page index: 1
Current page index after reloading page selection view: 0
Then in the executeExample method of the ViewController class after the strings:
// Display current page index after view reload in the development environment console NSLog(@"Current page index after reloading page selection view: %d", [pageSelector currentPage]);
add the following code:
// Delete all window subviews NSArray *reportSubviews = [self.view subviews]; for(UIView *subView in reportSubviews) { [subView removeFromSuperview]; } // Set background color [self.view setBackgroundColor:[UIColor whiteColor]]; // Get page thumbnail by specified index UIImage *thumbnail = [pageSelectorDelegate thumbnailByIndex:1]; // Display obtained image on mobile device screen UIImageView *imageView = [[UIImageView alloc] initWithImage:thumbnail]; [self.view addSubview:imageView];
After executing the updated example the mobile device screen displays the page thumbnail obtained by means of specified index:
Replace the strings:
// Display obtained image on mobile device screen
UIImageView *imageView = [[UIImageView alloc] initWithImage:thumbnail];
with the following code:
// Display current page thumbnail on mobile device screen UIImageView *imageView = [pageSelector selectedPageView];
After executing the updated example the mobile device screen displays the thumbnail of the regular report current page:
See also: