<< Click to Display Table of Contents >>
Running Viewer - iOS Viewer
Add OZ viewer into Xcode project, set OZ server information and report file name, and add a View to show OZ viewer.
Create Xcode project
Run Xcode and create a new project.
Select Single View Application in the Choose a template for your new project dialog box.
Set options such as Product Name and Company Identifier in the Choose options for your new project dialog. The Use Automatic Reference Counting option must be unchecked. Then click the Next button.
Select a path to save the project and click the Create button. The project will be created.
Add OZ viewer into Xcode project
Create a folder ("OZViewer" in this example) under the project path.
Copy the OZ Viewer installation file to the "OZViewer" folder.
Right click the project name in the Project Navigator window, and select Add Files to "project name" from the context menu. Select the "OZViewer" folder in the project path, check Create groups for any added folders option, check a project name in Add to targets, and click the Add button.
Write script
Write script in ViewController.h as below:
#import <UIKit/UIKit.h> #import "OZReportAPI.h"
@interface ViewController : UIViewController { IBOutlet UIView* _reportView; }
@property (nonatomic, strong) OZReportViewer* viewer;
@end |
Write script in ViewController.m as below:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; }
- (void) createViewer { NSString* strParam = @"connection.servlet=http://127.0.0.1:8080/oz/server\n" @"connection.reportname=category_path/sample.ozr"; OZReportViewer* reportViewer = [OZReportAPI createViewer:self view:_reportView param:strParam]; self.viewer = reportViewer; [reportViewer release]; }
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional stup after loading the view, typically from a nib. [self performSelector:@selector(createViewer) withObject:nil afterDelay:0.1]; }
- (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. }
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); }
@end |
View setup
Select ViewController.xib.
Add a View to display OZ Viewer and set properties and size in the Utilities window of the View.
Click File's Owner in Placeholders, and click Show the Connections inspector icon in the Utilities window of the View. Click the radio button at the right side of _reportView in Outlets, and drag OZ Viewer into the View area to show it.
Run Project
Run the project.