Adding Icon to Table Cell

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example describes adding of icon to table cell. 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 Creating a Simple Data Grid section):

// Create the first object with icon settings
NuGridCellImage *firstCellImage = [[NuGridCellImage new] autorelease];
// Determine icon for cell
UIImage *image = [UIImage imageNamed:@"box0.png"];
[firstCellImage setImage:image];
// Determine icon size
[firstCellImage setSize:CGSizeMake(30, 30)];
// Place icon at background
[firstCellImage setZPosition:NuImageZOrderBack];
// Place icon in the cell center
[firstCellImage setAlignment: NuImageHorizontalAlignmentRight];
// Determine icon border width
[firstCellImage setBorder:5.f];
// Create the second object with icon settings
NuGridCellImage *secondCellImage = [[NuGridCellImage new] autorelease];
// Determine icon for cell
UIImage *secondImage = [UIImage imageNamed:@"box1.png"];
[secondCellImage setImage:secondImage];
[secondCellImage setSize:CGSizeMake(25, 25)];
// Place icon at background
[secondCellImage setZPosition:NuImageZOrderBack];
// Place icon in the cell center
[secondCellImage setAlignment: NuImageVerticalAlignmentBottom];
// Determine width of left and bottom icons borders
[secondCellImage setLeftBorder:1.f];
[secondCellImage setBottomBorder:1.f];
NSMutableDictionary *images = [[NSMutableDictionary new] autorelease];
// Add the first icon to the B1 cell
[images setValue:firstCellImage forKey:@"cellImage0"];
[images setValue:[NSNumber numberWithInt:1] forKey:@"row0"];
[images setValue:[NSNumber numberWithInt:1] forKey:@"column0"];
// add the second icon to the C1 cell
[images setValue:secondCellImage forKey:@"cellImage1"];
[images setValue:[NSNumber numberWithInt:1] forKey:@"row1"];
[images setValue:[NSNumber numberWithInt:2] forKey:@"column1"];
// Display added icons
[proxyDatasource setDefaultCell:[CustomCell new]];
[[proxyDatasource defaultCell] setValue:images forKey:@"m_images"];

After executing the example the B1 and C1 cells have two different icons with different parameters added:

See also:

Examples of Component Use