Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example implements changing of selected table cell width, and also displaying of cell width change area size in the development environment console. Color settings of resize element are also changed, and resize marker image is changed.
Executing the example requires to place the following code instead of the executeExample method of the ViewController class (see the Creating a Simple Data Grid section):
-(void) executeExample{ // Set resize element color [contr setResizerColor:[UIColor redColor]]; // Set resize element border color [contr setResizerBorderColor:[UIColor greenColor]]; // Set new marker image for resize element [contr setResizerHandleImage:[UIImage imageNamed:@"circle.png"]]; // Create a table resize element NuGridResizer *resizer = [NuGridResizer resizerForGridView:[contr gridView]]; // Initialize resize element [resizer initWithGrid: [contr gridView]]; // Resize horizontal area used for resize CGSize size = CGSizeMake(90, 90); [resizer setLeftRightSelectionTouchAreaSize:size]; [contr setLeftRightSelectionTouchAreaSize:size]; // Set resize element [[contr gridView] setValue:resizer forKey:@"m_resizer"]; // Set start size of changed cell width colWidth = 80; }; // Handle table cell press event - (void)gridView:(NuGridView *)gridView wasTouchedInCell:(NuGridCell *)cell { // Start to change cell width [gridView addSubview:[gridView resizer]]; [[gridView resizer] resizeWidthForCell: cell]; } // Handle cell width change event - (void)gridView:(NuGridView *)gridView widthChangeNeeded:(double)newWidth forCell:(NuGridCell *)cell { // Finish cell change if its width exceeds 400 pixels if(newWidth > 400) { [[gridView resizer] finish]; } // Save cell width value colWidth = newWidth; // Stretch resize area after it was changed [[gridView resizer] stretchAfterChanging]; // Display resize area size NSInteger frameWidth = [[gridView resizer] originFrame].size.width; NSInteger frameHeight = [[gridView resizer] originFrame].size.height; NSLog(@"%@ (%d, %d)", @"Resize area size:", frameWidth, frameHeight); }
It is also required to place the following code instead of the widthForColumn method of the ViewController class:
// Set column width - (double)gridView:(NuGridView *)gridView widthForColumn:(NSInteger)columnNumber { if(columnNumber == 2) { return colWidth; } else { return 80; } }
Press any table cell, which is in the column with the number 2, after which change its width by dragging the marker.
As a result, the selected cell width is changed:
On each resize the development environment console displays value of cell width resize area size:
Resize area size: (127, 283)
See also: