Getting View Controller Delegate in Regular Report Viewer

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example describes getting a view controller delegate in regular report viewer.

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

// 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 sheet viewer
    if([controller isMemberOfClass:[MAProceduralReportDataViewController class]])
    {
        // Get sheet viewer view
        MAProceduralReportDataViewController *dataViewController =(MAProceduralReportDataViewController *)controller;
        // Get regular report viewer view
        MAProceduralReportDataViewControllerBase *reportDataViewControllerBase = (MAProceduralReportDataViewControllerBase *)dataViewController;
        // Get view controller delegate
        id<MADataViewControllerDelegate> dataViewControllerBaseDelegate = [reportDataViewControllerBase delegate];
        // Check if obtained delegate inherits from the UIViewController class
        if([dataViewControllerBaseDelegate isKindOfClass:[UIViewController class]])
        {
            // Transform delegate to the UIViewController type
            UIViewController *reportController = (UIViewController *)dataViewControllerBaseDelegate;
            // Get delegate display borders
            CGRect bounds =[[reportController view] bounds];
            // Display image width and height in the development environemnt console
            NSLog(@"View controller delegate display width in regular report viewer: %f", bounds.size.width);
            NSLog(@"View controller delegate display height in regular report viewer: %f", bounds.size.height);
        }
    }
}

After executing the example the development environment console displays obtained delegate display size:

View controller delegate display width in regular report viewer: 768.000000

View controller delegate display height in regular report viewer: 960.000000

See also:

Examples of Component Use