代码改变世界

ios中封装九宫格的使用(二级导航)

2013-08-08 18:00  甘超波  阅读(509)  评论(0编辑  收藏  举报

 

效果图 一般用于导航功能

第一步下载http://pan.baidu.com/share/link?shareid=1824940819&uk=923776187 

第二步 把下图内容放在你的xcode中

项目中用法

//第一步引用头文件 #import "DIYTableView.h"

//第二步实现代理 DIYButtonDelegate

//第三步 引入实体 InvoiceInfo.h

//第四步 随机生成数据

 //第五步 初始化 DIYTableView 并设置代理

   //第六步 设置数据源

//第七步设置代理

其中在 “DIYCell.h”中设置

 

#define KCount 10设置一排显示多少按钮

#define Kpadding 25设置两个按钮之间的间距

#import <UIKit/UIKit.h>
//第一步引用头文件 #import "DIYTableView.h"
#import "DIYTableView.h"

//第二步实现代理 DIYButtonDelegate
@interface JGGViewController : UIViewController<DIYButtonDelegate>

@end
#import "JGGViewController.h"
//第三步 引入实体 InvoiceInfo.h
#import "InvoiceInfo.h"

@interface JGGViewController ()

@end

@implementation JGGViewController


- (void)viewDidLoad
{
    [super viewDidLoad];
    //第四步 随机生成数据
    NSMutableArray *data=[NSMutableArray array];
    for (int i=0; i<10; i++) {
        InvoiceInfo *info=[[InvoiceInfo alloc] init];
        info.name=[NSString stringWithFormat:@"it--%zi",i];//name
        info.iPad_ctrls=@"controllername";
        info.imagUrl=@"icon_weixin";//图片
        [data addObject:info];
        [info release];
    }
    
    
    
   //第五步 初始化 DIYTableView 并设置代理
    DIYTableView *view=[[DIYTableView alloc] initWithFrame:self.view.bounds delegate:self];
    //第六步 设置数据源
    view.aData=data;
    [self.view addSubview:view];
}

//第七步 设置代理
#pragma mark -代理方法
-(void)DiyButtonClick:(DIYButton *)btn{
    NSLog(@"name--%@-->controller-->%@",btn.titleLabel.text,btn.ctrlName);
}



@end