IOS超强表格控件GMGridView

Posted pengyuan_D

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IOS超强表格控件GMGridView相关的知识,希望对你有一定的参考价值。

ios为我们提供UITableView类,实现了项目的纵向排列,而对于iOS整个操作桌面,所有应用程序却是以网格的形式排列,Gulam Moledina帮我们实现了这个效果,而且留有的接口与UITableView类似,使用起来相当方便。

需要的环境支持:

    1iOS5,需要UIScrollView手势支持;

    2ARC(Automatic Reference Counting自动引用计数)

    3、框架Frameworks: Foundation, UIKit, CoreGraphics and QuartzCore


简单解析:

属性:

layoutStrategy和style属性,用来设置显示样式。

editing属性,是否进入编辑状态。

minEdgeInsets属性设置项目与项目直接的间隔。

代理dataSource,actionDelegate,sortingDelegate,transformDelegate接收数据或是处理事件。

代理:

GMGridViewDataSource项目的多少以及样子(cell)

GMGridViewActionDelegate重点捕获了,项目被点击的事件

GMGridViewSortingDelegate项目重排时一系列事件

GMGridViewTransformationDelegate项目状态改变时的变化

方法:

- (void)reloadData;//最常用的重新加载数据

- (void)insertObjectAtIndex:(NSInteger)index animated:(BOOL)animated;//插入

- (void)removeObjectAtIndex:(NSInteger)index animated:(BOOL)animated;//移除

- (void)reloadObjectAtIndex:(NSInteger)index animated:(BOOL)animated;//重载

- (void)swapObjectAtIndex:(NSInteger)index1 withObjectAtIndex:(NSInteger)index2 animated:(BOOL)animated;//排序项目

AppDelegate.m
RootViewController *root = [[RootViewController alloc] init];
    self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:root];

RootViewController.h
#import <UIKit/UIKit.h>
#import "GMGridView.h"

@interface RootViewController : UIViewController<GMGridViewDataSource,GMGridViewActionDelegate,GMGridViewSortingDelegate,GMGridViewTransformationDelegate>


    GMGridView *_gmGridView;
    UIPopoverController *_optionsPopOver;
    UINavigationController *_optionNav;
    NSMutableArray *_array;

RootViewController.m
#import "RootViewController.h"
#import "GMGridView.h"
#import "OptionsViewController.h"

#define NUMBER_ITEMS_ON_LOAD 10
@interface RootViewController ()
- (void)addMoreItem;
- (void)removeItem;
- (void)refreshItem;
- (void)presentInfo;
//- (void)presentOptions:(UIBarButtonItem *)barButton;

@end

@implementation RootViewController

- (id)init

    if ((self =[super init]))
    
        self.title = @"Root";

        UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addMoreItem)];

        UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
        space.width = 10;

        UIBarButtonItem *removeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(removeItem)];

        UIBarButtonItem *space2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
        space2.width = 10;

        UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshItem)];

        if ([self.navigationItem respondsToSelector:@selector(leftBarButtonItems)]) 
            self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:addButton, space, removeButton, space2, refreshButton, nil];
        else 
            self.navigationItem.leftBarButtonItem = addButton;
        

        UIBarButtonItem *optionsButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(presentOptions:)];

        if ([self.navigationItem respondsToSelector:@selector(rightBarButtonItems)]) 
            self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:optionsButton, nil];
        else 
            self.navigationItem.rightBarButtonItem = optionsButton;
        

        _array = [[NSMutableArray alloc] init];

        for (int i = 0; i < NUMBER_ITEMS_ON_LOAD; i ++)
        
            [_array addObject:[NSString stringWithFormat:@"%d", i]];
        

    

    return self;


- (void)viewDidLoad

    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;


- (void)loadView 
    [super loadView];
    self.view.backgroundColor = [UIColor whiteColor];
    _gmGridView = [[GMGridView alloc] initWithFrame:self.view.bounds];
    _gmGridView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    _gmGridView.backgroundColor = [UIColor clearColor];
    _gmGridView.dataSource = self;
    _gmGridView.actionDelegate = self;
    _gmGridView.sortingDelegate = self;
    _gmGridView.transformDelegate = self;
    _gmGridView.centerGrid = YES;
    _gmGridView.style = GMGridViewStyleSwap;
    _gmGridView.minEdgeInsets = UIEdgeInsetsMake(5, 10, -5, 10);//项目之间的间隔
    _gmGridView.itemSpacing = 10;
    _gmGridView.itemHSpacing = 20;
    [self.view addSubview:_gmGridView];

    UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoDark];
    infoButton.frame = CGRectMake(self.view.bounds.size.width - 40,
                                  self.view.bounds.size.height - 40,
                                  40,
                                  40);
    infoButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
    [infoButton addTarget:self action:@selector(presentInfo) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:infoButton];

    OptionsViewController *optionCtrl = [[OptionsViewController alloc] init];
    optionCtrl.gmGridView = _gmGridView;
    //optionCtrl.contentSizeForViewInPopover = CGSizeMake(400, 500);

    _optionNav = [[UINavigationController alloc] initWithRootViewController:optionCtrl];
    if (INTERFACE_IS_PHONE)
    
        UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(optionsDoneAction)];
        optionCtrl.navigationItem.rightBarButtonItem = doneButton;
    


//单元格个数
#pragma mark - GMGridViewDataSource
- (NSInteger)numberOfItemsInGMGridView:(GMGridView *)gridView 
    return _array.count;

//大小
- (CGSize)sizeForItemsInGMGridView:(GMGridView *)gridView 
    CGSize size = CGSizeMake(70, 100);
    return size;

//创建单元格
- (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index 
    CGSize size = [self sizeForItemsInGMGridView:gridView];

    GMGridViewCell *cell = [gridView dequeueReusableCell];

    if (!cell)
    
        cell = [[GMGridViewCell alloc] init];
        cell.deleteButtonIcon = [UIImage imageNamed:@"close_x.png"];
        cell.deleteButtonOffset = CGPointMake(-15, -15);

        UIImageView *bookView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"book.png"]];
        [bookView setFrame:CGRectMake(0, 0, size.width,size.height)];

        cell.contentView = bookView;
    

    [[cell.contentView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];

    return cell;


- (void)GMGridView:(GMGridView *)gridView deleteItemAtIndex:(NSInteger)index
    [_array removeObjectAtIndex:index];

//点击单元格调用的方法
#pragma mark - GMGridViewActionDelegate
- (void)GMGridView:(GMGridView *)gridView didTapOnItemAtIndex:(NSInteger)position

    NSLog(@"Did tap at index:%d",position);


#pragma mark - GMGridViewSortingDelegate
//开始拖动单元格调用的方法
- (void)GMGridView:(GMGridView *)gridView didStartMovingCell:(GMGridViewCell *)cell 
    [UIView animateWithDuration:.3 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^
        cell.contentView.backgroundColor = [UIColor cyanColor];
        //阴影宽度
        cell.contentView.layer.shadowOpacity = .7;
     completion:nil];


//单元格结束拖动调用的方法
- (void)GMGridView:(GMGridView *)gridView didEndMovingCell:(GMGridViewCell *)cell
    
        [UIView animateWithDuration:.3 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^
            cell.contentView.backgroundColor = [UIColor cyanColor];
            cell.contentView.layer.shadowOpacity = 0;
         completion:nil];
    
// Enable/Disable the shaking behavior of an item being moved
- (BOOL)GMGridView:(GMGridView *)gridView shouldAllowShakingBehaviorWhenMovingCell:(GMGridViewCell *)view atIndex:(NSInteger)index 

    return YES;

- (void)GMGridView:(GMGridView *)gridView moveItemAtIndex:(NSInteger)oldIndex toIndex:(NSInteger)newIndex 

    NSObject *object = [_array objectAtIndex:oldIndex];
    [_array removeObject:object];
    [_array insertObject:object atIndex:newIndex];

//交换下标位置
- (void)GMGridView:(GMGridView *)gridView exchangeItemAtIndex:(NSInteger)index1 withItemAtIndex:(NSInteger)index2 

    [_array exchangeObjectAtIndex:index1 withObjectAtIndex:index2];


#pragma mark - GMGridViewTransformationDelegate 项目状态改变时的变化
- (CGSize)GMGridView:(GMGridView *)gridView sizeInFullSizeForCell:(GMGridViewCell *)cell atIndex:(NSInteger)index 
    NSLog(@"hello");
    return CGSizeMake(310, 310);

- (UIView *)GMGridView:(GMGridView *)gridView fullSizeViewForCell:(GMGridViewCell *)cell atIndex:(NSInteger)index 
    UIView *fullView = [[UIView alloc] init];
    fullView.backgroundColor = [UIColor orangeColor];
    fullView.layer.masksToBounds = NO;
    fullView.layer.cornerRadius = 8;
    CGSize size = [self GMGridView:gridView sizeInFullSizeForCell:cell atIndex:index];
    fullView.bounds = CGRectMake(0, 0, size.width, size.height);

    UILabel *label = [[UILabel alloc] initWithFrame:fullView.bounds];
    label.text = [NSString stringWithFormat:@"my label %ld",index];
    label.textAlignment = NSTextAlignmentCenter;
    label.backgroundColor = [UIColor clearColor];
    label.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    label.font = [UIFont boldSystemFontOfSize:15];
    [fullView addSubview:label];
    return fullView;


// Transformation (pinch, drag, rotate) of the item
- (void)GMGridView:(GMGridView *)gridView didStartTransformingCell:(GMGridViewCell *)cell 
    [UIView animateWithDuration:0.5
                          delay:0
                        options:UIViewAnimationOptionAllowUserInteraction
                     animations:^
                         cell.contentView.backgroundColor = [UIColor blueColor];
                         cell.contentView.layer.shadowOpacity = 0.7;
                     
                     completion:nil];

- (void)GMGridView:(GMGridView *)gridView didEnterFullSizeForCell:(GMGridViewCell *)cell 
    [UIView animateWithDuration:0.5
                          delay:0
                        options:UIViewAnimationOptionAllowUserInteraction
                     animations:^
                         cell.contentView.backgroundColor = [UIColor blueColor];
                         cell.contentView.layer.shadowOpacity = 0;
                     
                     completion:nil];


- (void)GMGridView:(GMGridView *)gridView didEndTransformingCell:(GMGridViewCell *)cell 
    NSLog(@"did END");


#pragma mark private methods
//

- (void)addMoreItem

    // Example: adding object at the last position
    NSString *newItem = [NSString stringWithFormat:@"%d", (int)(arc4random() % 1000)];

    [_array addObject:newItem];
    [_gmGridView insertObjectAtIndex:[_array count] - 1];


- (void)removeItem

    // Example: removing last item
    if ([_array count] > 0)
    
        NSInteger index = [_array count] - 1;

        [_gmGridView removeObjectAtIndex:index];
        [_array removeObjectAtIndex:index];
    


- (void)refreshItem

    // Example: reloading last item
    if ([_array count] > 0)
    
        int index = [_array count] - 1;

        NSString *newMessage = [NSString stringWithFormat:@"%d", (arc4random() % 1000)];

        [_array replaceObjectAtIndex:index withObject:newMessage];
        [_gmGridView reloadObjectAtIndex:index];
    


- (void)presentInfo

    NSString *info = @"Long-press an item and its color will change; letting you know that you can now move it around. \\n\\nUsing two fingers, pinch/drag/rotate an item; zoom it enough and you will enter the fullsize mode";

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Info"
                                                        message:info
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];

    [alertView show];


- (void)presentOptions:(UIBarButtonItem *)barButton

    if (INTERFACE_IS_PHONE)
    
        [self presentViewController:_optionNav animated:YES completion:nil];
    
    else
    
        if(![_optionsPopOver isPopoverVisible])
        
            if (!_optionsPopOver)
            
                _optionsPopOver = [[UIPopoverController alloc] initWithContentViewController:_optionNav];
            

            [_optionsPopOver presentPopoverFromBarButtonItem:barButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        
        else
        
            [self optionsDoneAction];
        
    


- (void)optionsDoneAction

    if (INTERFACE_IS_PHONE)
    
        [self dismissViewControllerAnimated:YES completion:nil];
    
    else
    
        [_optionsPopOver dismissPopoverAnimated:YES];
    


@end
OptionsViewController.h
#import <UIKit/UIKit.h>
@class GMGridView;
@interface OptionsViewController : UIViewController<UITableViewDelegate,UITableViewDataSource,UIPickerViewDataSource,UIPickerViewDelegate>


    UITableView *_tableView;

@property (nonatomic,retain)GMGridView *gmGridView;
@end
OptionsViewController.m
#import "OptionsViewController.h"
#import "GMGridView.h"
#import "GMGridViewLayoutStrategies.h"
// Sections
typedef enum

    OptionSectionGeneral = 0,
    OptionSectionLayout,
    OptionSectionSorting,
    OptionSectionDebug,
    OptionSectionsCount
 OptionsTypeSections;

// General
typedef enum

    OptionTypeGeneralEditing = 0,
    OptionGeneralCount
 OptionsTypeGeneral;

// Options layout
typedef enum 
    OptionTypeLayoutStrategy = 0,
    OptionsTypeLayoutSpacing,
    OptionsTypeLayoutCenter,
    OptionsTypeLayoutMinInsets,
    OptionLayoutCount
 OptionsTypeLayout;

// Options sorting
typedef enum 
    OptionTypeSortingStyle = 0,

    OptionSortingCount
 OptionsTypeSorting;

// Options debug
typedef enum 
    OptionTypeDebugGridBackground = 0,
    OptionTypeDebugReload,

    OptionDebugCount
 OptionsTypeDebug;

@interface OptionsViewController ()

//- (void)editingSwitchChanged:(UISwitch *)control;
//- (void)sortStyleSegmentedControlChanged:(UISegmentedControl *)control;
//- (void)layoutCenterSwitchChanged:(UISwitch *)control;
//- (void)layoutSpacingSliderChanged:(UISlider *)control;
//- (void)layoutInsetsSliderChanged:(UISlider *)control;
//- (void)debugGridBackgroundSwitchChanged:(UISwitch *)control;
//- (void)debugReloadButtonPressed:(UIButton *)control;

@end

@implementation OptionsViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) 
        // Custom initialization
    
    return self;


- (void)viewDidLoad

    [super viewDidLoad];
    _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    _tableView.backgroundColor = [UIColor grayColor];
    
    [self.view addSubview:_tableView];

    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.navigationController.navigationBar.barTintColor = [UIColor blackColor];


#pragma  mark - UITableViewDataSource&UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

    return 35;




- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

    static NSString *cellIdentifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if (!cell)
    
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    


    if ([indexPath section] == OptionSectionGeneral)
    
        switch ([indexPath row])
        
            case OptionTypeGeneralEditing:
            
                cell.detailTextLabel.text = @"Editing";

                UISwitch *editingSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
                [editingSwitch addTarget:self action:@selector(editingSwitchChanged:) forControlEvents:UIControlEventValueChanged];
                editingSwitch.on = self.gmGridView.isEditing;

                cell.accessoryView = editingSwitch;
            
        
    
    else if ([indexPath section] == OptionSectionLayout)
    
        switch ([indexPath row])
        
            case OptionTypeLayoutStrategy:
            
                cell.detailTextLabel.text = @"NULL";

                UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:cell.contentView.bounds];
                pickerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
                pickerView.showsSelectionIndicator = YES;
                pickerView.delegate = self;
                pickerView.dataSource = self;

                switch ([self.gmGridView.layoutStrategy type])
                
                    case GMGridViewLayoutVertical:
                    default:
                        [pickerView selectRow:0 inComponent:0 animated:YES];
                        break;
                

                cell.contentView.clipsToBounds = YES;
                [cell.contentView addSubview:pickerView];

                break;
            
            case OptionsTypeLayoutCenter:
            
                cell.detailTextLabel.text = @"Center";

                UISwitch *centerSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
                [centerSwitch addTarget:self action:@selector(layoutCenterSwitchChanged:) forControlEvents:UIControlEventValueChanged];
                centerSwitch.on = self.gmGridView.centerGrid;

                cell.accessoryView = centerSwitch;

                break;
            
            case OptionsTypeLayoutSpacing:
            
                cell.detailTextLabel.text = @"Spacing";

                UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];
                [slider setMinimumValue:0];
                [slider setMaximumValue:20];
                [slider setValue:self.gmGridView.itemSpacing];
                [slider setContinuous:NO];
                [slider addTarget:self action:@selector(layoutSpacingSliderChanged:) forControlEvents:UIControlEventValueChanged];

                cell.accessoryView = slider;

                break;
            
            case OptionsTypeLayoutMinInsets:
            
                cell.detailTextLabel.text = @"Edge insets";

                UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];
                [slider setMinimumValue:0];
                [slider setMaximumValue:50];
                [slider setValue:self.gmGridView.minEdgeInsets.top];
                [slider setContinuous:NO];
                [slider addTarget:self action:@selector(layoutInsetsSliderChanged:) forControlEvents:UIControlEventValueChanged];

                cell.accessoryView = slider;
                break;
            
        
    
    else if ([indexPath section] == OptionSectionSorting)
    
        switch ([indexPath row])
        
            case OptionTypeSortingStyle:
            
                cell.detailTextLabel.text = @"Style";

                UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Swap", @"Push", nil]];
                segmentedControl.frame = CGRectMake(0, 0, 150, 30);
                [segmentedControl addTarget:self action:@selector(sortStyleSegmentedControlChanged:) forControlEvents:UIControlEventValueChanged];
                segmentedControl.selectedSegmentIndex = (self.gmGridView.style == GMGridViewStylePush) ? 1 : 0;

                cell.accessoryView = segmentedControl;

                break;
            
        
    
    else if ([indexPath section] == OptionSectionDebug)
    
        switch ([indexPath row])
        
            case OptionTypeDebugGridBackground:
            
                cell.detailTextLabel.text = @"Grid background color";

                UISwitch *backgroundSwitch = [[UISwitch alloc] init];
                [backgroundSwitch addTarget:self action:@selector(debugGridBackgroundSwitchChanged:) forControlEvents:UIControlEventValueChanged];
                backgroundSwitch.on = (self.gmGridView.backgroundColor != [UIColor clearColor]);
                [backgroundSwitch sizeToFit];

                cell.accessoryView = backgroundSwitch;

                break;
            
            case OptionTypeDebugReload:
            
                cell.detailTextLabel.text = @"Reload from Datasource";

                UIButton *reloadButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
                [reloadButton setReversesTitleShadowWhenHighlighted:YES];
                [reloadButton setTitleColor:[UIColor redColor] forState:UIControlEventTouchUpInside];
                [reloadButton setTitle:@"Reload" forState:UIControlStateNormal];
                [reloadButton addTarget:self action:@selector(debugReloadButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
                [reloadButton sizeToFit];

                cell.accessoryView = reloadButton;

                break;
            
        
    
    
    return cell;




- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
    CGFloat height = 45;
    if (indexPath.section == OptionSectionLayout) 
        switch (indexPath.row) 
            case OptionTypeLayoutStrategy:
                height = 160;
                break;
        
    
    return height;

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    return OptionSectionsCount;


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
    NSInteger count = 0;
    switch (section) 
        case OptionSectionGeneral:
            count = OptionGeneralCount;
             break;
        case OptionSectionLayout:
            count = OptionLayoutCount;
             break;
        case OptionSectionSorting:
            count = OptionSortingCount;
            break;
        case OptionSectionDebug:
            count = OptionDebugCount;
            break;
    
    return count;


- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
    NSString *title = @"UnKnown";
    switch (section) 
        case OptionSectionGeneral:
            title = @"General";
            break;
        case OptionSectionLayout:
            title = @"Layout";
        case OptionSectionSorting:
            title = @"Sorting";
        case OptionSectionDebug:
            title = @"Debug";
            break;
    
    return title;

#pragma mark - UIPickerViewDataSource & UIPickerViewDelegate 
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component

    self.gmGridView.layoutStrategy = [GMGridViewLayoutStrategyFactory strategyFromType:GMGridViewLayoutVertical];


- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView

    return 1;


- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component

    return 4;


- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component

    NSString *title = nil;
    title = @"Vertical strategy";

    return title;


#pragma mark Control callbacks
//

- (void)editingSwitchChanged:(UISwitch *)control

    self.gmGridView.editing = control.on;
    //control.on = self.gmGridView.isEditing;


- (void)sortStyleSegmentedControlChanged:(UISegmentedControl *)control

    switch (control.selectedSegmentIndex)
    
        case 1:
            self.gmGridView.style = GMGridViewStylePush;
            break;
        case 0:
        default:
            self.gmGridView.style = GMGridViewStyleSwap;
            break;
    


- (void)layoutInsetsSliderChanged:(UISlider *)control

    self.gmGridView.minEdgeInsets = UIEdgeInsetsMake(control.value, control.value, control.value, control.value);

- (void)layoutCenterSwitchChanged:(UISwitch *)control

    self.gmGridView.centerGrid = control.on;


- (void)layoutSpacingSliderChanged:(UISlider *)control

    self.gmGridView.itemSpacing = control.value;

- (void)debugGridBackgroundSwitchChanged:(UISwitch *)control
    self.gmGridView.backgroundColor = control.on ? [UIColor lightGrayColor] : [UIColor clearColor];

- (void)debugReloadButtonPressed:(UIButton *)control

    [self.gmGridView reloadData];

@end




以上是关于IOS超强表格控件GMGridView的主要内容,如果未能解决你的问题,请参考以下文章

iOS 8 - 切换控件后,即使在纵向模式下,旋转也会使状态栏消失

Flutter 基础控件之 Row 横向布局 Column 纵向布局

GridView 单元格向上滚动到 iOS 7 中的状态栏

Xcode 5 头文件未找到?

ios 轮换最佳实践

QT绘图技术QCustomPlot - 超强超小巧的qt绘图控件