Creating a Regular Report Sheet Viewer

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example describes creating a regular report sheet viewer. After starting the example the following operations are executed:

Source Code

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):

// Delete all window subviews
NSArray *reportSubviews = [self.view subviews];
for(UIView *subView in reportSubviews)
{
    [subView removeFromSuperview];
}
// Get regular report view
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 sheet viewer
    if([controller isMemberOfClass:[MAProceduralReportDataViewController class]])
    {
        // Get sheet viewer view
        MAProceduralReportDataViewController *dataViewController =(MAProceduralReportDataViewController *)controller;
        // Get regular report data source from sheet viewer view
        id<MAProceduralReportViewControllerDelegate> dataSource = [dataViewController dataSource];
        // Create a new sheet viewer view
        MAProceduralReportDataViewController *createdDataViewController = [[MAProceduralReportDataViewController alloc] initWithDataSource:dataSource];
        // Get regular report viewer view
        MAProceduralReportDataViewControllerBase *reportDataViewControllerBase = (MAProceduralReportDataViewControllerBase *)createdDataViewController;
        // Get PNG data of report first page for screenshot
        NSData *firstPageData = [reportDataViewControllerBase prepareScreenshotOfTheFirstPage];
        // Create an image based on obtained data
        UIImage *image = [[UIImage alloc] initWithData:firstPageData];
        // Set window background color
        [self.view setBackgroundColor:[UIColor whiteColor]];
        // Display obtained image in the mobile device screen
        UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
        [self.view addSubview:imageView];
    }
}

After executing the example the mobile device screen displays a thumbnail of the regular report first page:

See also:

Examples of Component Use