Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example shows loading of dashboard block view. The development environment console displays the following block data:
Information about block bindings to window borders.
Bock margin values.
Block shadow information.
Block color information.
Block border information.
Block background gradient information.
Dashboard block size.
Block name.
Block description.
Block type.
Block key.
Block element name.
Property values of specified types of blocks.
Executing the example requires to place the following code instead of the executeExample method of the ViewController class (see the Displaying of Dashboard section):
// Get dashboard controller MADashboardReportViewController *controller = (MADashboardReportViewController*)m_controller; if ([[[controller report] compositeBlocks] count] > 0) { // Get dashboard block APCompositeBlock *block = [[[controller report] compositeBlocks] allValues][0]; // Load view if it is not loaded if([block view] != nil){ [block loadView]; // Inform the block that subviews are loaded if([block isViewLoaded]) [block viewDidLayoutSubviews]; } // Display information about dashboard block anchors NSLog(@"Whether block is anchored to window top border: %hhd", [block anchorTop]); NSLog(@"Whether block is anchored to window bottom border: %hhd", [block anchorBottom]); NSLog(@"Whether block is anchored to window left border: %hhd", [block anchorLeft]); NSLog(@"Whether block is anchored to window right border: %hhd", [block anchorRight]); // Display information about dashboard block paddings if([block usePaddings]){ NSLog(@"Block top padding values: %f", [block paddingTop]); NSLog(@"Block bottom padding values: %f", [block paddingBottom]); NSLog(@"Block left padding values: %f", [block paddingLeft]); NSLog(@"Block right padding values: %f", [block paddingRight]); } // Display information about dashboard block shadow if([block useShadow]){ const CGFloat *c = CGColorGetComponents([block shadowColor].CGColor); NSLog(@"Block shadow color components: R:%f G:%f B:%f A:%f", c[0], c[1], c[2], c[3]); NSLog(@"Block shadow transparency value: %f", [block shadowOpacity]); NSLog(@"Block shadow width values: %f", [block shadowWidth]); } // Display information about dashboard block background if([block useBackground]){ const CGFloat *c = CGColorGetComponents([block backgroundColor].CGColor); NSLog(@"Block background color components: R:%f G:%f B:%f A:%f", c[0], c[1], c[2], c[3]); } // Display information about dashboard block borders if([block useBorder]){ const CGFloat *c = CGColorGetComponents([block borderColor].CGColor); NSLog(@"Block border color components: R:%f G:%f B:%f A:%f", c[0], c[1], c[2], c[3]); NSLog(@"Dashboard block border width: %f", [block borderWidth]); } // Display information about rounding of dashboard block border corners if([block useBorderRadius]){ NSLog(@"Rounding radius of border corners: %f", [block cornerRadius]); } // Display information about dashboard block gradient if([block useGradient]){ const CGFloat *c = CGColorGetComponents([block gradientColor].CGColor); NSLog(@"Gradient color components: R:%f G:%f B:%f A:%f", c[0], c[1], c[2], c[3]); NSLog(@"Gradient angle: %f", [block gradientAngle]); } // Display dashboard block size if([block hasWidth]) NSLog(@"Dashboard block width: %f", [block width]); if([block hasHeight]) NSLog(@"Dashboard block height: %f", [block height]); // Get array of dashboard block attributes NSDictionary *attributes = [block attributes]; // Display dashboard block name NSLog(@"Dashboard block name: %@", [attributes valueForKey:@"name"]); // Display description, type and key of dashboard block if([block tag] != nil) NSLog(@"Dashboard block description: %@", [block tag]); if([block type] != nil) NSLog(@"Dashboard block type: %@", [block type]); if([block key] != nil) NSLog(@"Dashboard block key: %@", [block key]); // Display number of dashboard blocks NSLog(@"Number of dashboard blocks: %d", [[[block kap] compositeBlocks] count]); // Create a copy of dashboard block APXMLParserObject *data = [block data]; APCompositeBlock *copy = [[APCompositeBlock new] autorelease]; [copy initWithParserObject:data kap:[block kap]]; // Create and set properties dictionary NSArray *valArray = [NSArray arrayWithObjects:@"string", [NSNumber numberWithBool:YES], [NSNumber numberWithDouble:42.42], [NSNumber numberWithInt:42], nil]; NSArray *keyArray = [NSArray arrayWithObjects:@"stringKey", @"boolKey", @"doubleKey", @"intKey", nil]; NSMutableDictionary *props = [NSMutableDictionary dictionaryWithObjects:valArray forKeys:keyArray]; [copy setValue:props forKey:@"m_properties"]; // Display dashboard block element name APXMLParserObject *obj = [copy propForKey:[[[copy objects][0] attributes] allValues][0]]; NSLog(@"Dashboard block element name: %@", [obj elementName]); // Display values of properties of specified types if([[copy properties] count] != 0){ if([copy hasPropForKey:@"stringKey"]) NSLog(@"String-type property value: %@", [copy stringPropForKey:@"stringKey"]); NSLog(@"Logical-type property value: %hhd", [copy boolPropForKey:@"boolKey"]); NSLog(@"Real-type property value: %f", [copy doublePropForKey:@"doubleKey"]); NSLog(@"Integer-type property value: %i", [copy intPropForKey:@"intKey"]); } } else { NSLog(@"No dashboard blocks"); }
As a result, the development environment console displays information about dashboard block:
Whether block is anchored to window top border: 1
Whether block is anchored to window bottom border: 1
Whether block is anchored to window left border: 1
Whether block is anchored to window right border: 1
Block background color components: R:1.000000 G:1.000000 B:1.000000 A:1.000000
Block border color components: R:0.788235 G:0.788235 B:0.788235 A:1.000000
Dashboard block border width: 1.000000
Dashboard block width: 348.923077
Dashboard block height: 190.666667
Dashboard block name: Table
Dashboard block type: Table
Dashboard block key: 7HBEWOKE7UKGM6VB
Number of dashboard blocks: 1
Dashboard block element name: prop
String-type property value: string
Logical-type property value: 1
real-type property value: 42.420000
Integer-type property value: 42
See also: