结合网格

tabbar控制器加子视图控制器
自定义cell以及自定义view还有网格的结合


#import "ONEViewController.h"
#import "CKSlideMenu.h"
#import "jinriViewController.h"
#import "yuleViewController.h"
#import "fuckViewController.h"

@interface ONEViewController ()

@end

@implementation ONEViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    NSArray *titles = @[@"今日",@"阿萨德",@"爱迪生",@"暗示",@"说的",@"粉丝",@"阿萨德",@"爱迪生",@"暗示",@"说的"];
    jinriViewController *ONE = [[jinriViewController alloc]init];
    ONE.title = @"fff";
    yuleViewController *Two = [[yuleViewController alloc]init];
    Two.title = @"bbb";
    NSArray *array = @[ONE,Two];
    NSMutableArray *arr = [NSMutableArray array];
    for (int i = 0; i <2 ; i++) {
        [arr addObject:array[i]];
        
    }
    
    CKSlideMenu *slideMenu = [[CKSlideMenu alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width-60, 40) titles:titles controllers:arr];
    slideMenu.bodyFrame = CGRectMake(0, 64+40, self.view.frame.size.width, self.view.frame.size.height-64-40);
    [slideMenu scrollToIndex:3];
    [self.view addSubview:slideMenu];
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(360, 50, 60, 64)];
    [btn setTitle:@"++++" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [self.view addSubview:btn];
    [btn addTarget:self action:@selector(abc) forControlEvents:UIControlEventAllEvents];
    
    
}
-(void)abc{
    
    fuckViewController *fuck = [[fuckViewController alloc]init];
    [self.navigationController pushViewController:fuck animated:YES];
    
    
    
    
    
}

@end



自定义view   网格

#import “zdy.h”

@implementation zdy

-(instancetype)initWithFrame:(CGRect)frame{
if (self== [super initWithFrame:frame]) {
[self vie];
}
return self;
}
-(void)vie{
NSArray *arr=@[@“1”,@“2”,@“3”,@“4”];
for ( int i=0; i<arr.count; i++) {
UIButton btn=[[UIButton alloc] initWithFrame:CGRectMake(7+100i, 0, 100, 80)];
[btn setBackgroundImage:[UIImage imageNamed:arr[i]] forState:UIControlStateNormal];
btn.tag=100+i;
[self addSubview:btn];
}
}
@end

网格
#import “fuckViewController.h”

@interface fuckViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
{
UICollectionView *coll;

}

@end

@implementation fuckViewController

  • (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor orangeColor];
    self.title=@“频道管理”;
    //网格
    UICollectionViewFlowLayout *fl=[[UICollectionViewFlowLayout alloc] init];
    fl.minimumLineSpacing=0;
    fl.minimumInteritemSpacing=0;
    fl.itemSize=CGSizeMake(100, 100);

    coll=[[UICollectionView alloc] initWithFrame:self.view.frame collectionViewLayout:fl];
    coll.delegate=self;
    coll.dataSource=self;
    [coll registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@“cell”];
    coll.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:coll];

}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 16;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
NSArray *arr=@[@"11",@"22",@"33",@"44",@"55",@"66",@"77",@"88",@"111",@"1222",@"1333",@"1444",@"99",@"100",@"",@""];
UIView *vie=[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 300)];
UIImageView *img=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
img.image=[UIImage imageNamed:arr[indexPath.row]];
[vie addSubview:img];
[cell addSubview:vie];

return cell;

}
//隐藏标签控制器

  • (void)viewWillAppear:(BOOL)animated{
    self.tabBarController.tabBar.hidden = YES;
    }
  • (void)viewWillDisappear:(BOOL)animated{
    self.tabBarController.tabBar.hidden = NO;
    }
    @end

子控制器显示表格



#import "jinriViewController.h"
#import "hahaTableViewCell.h"
#import "zdy.h"

@interface jinriViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic , strong) UITableView *tableview;
@property(nonatomic , strong) zdy *viewone;
@end

@implementation jinriViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    [self.view addSubview:self.tableview];
    
    
    self.tableview.tableHeaderView = self.viewone;
    
    
    
    
    
}
-(zdy *)viewone{
    if (_viewone == nil) {
        _viewone = [[zdy alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 80)];
    }
    return _viewone;
}



-(UITableView *)tableview{
    if (_tableview == nil) {
        _tableview  = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
        _tableview.delegate = self;
        _tableview.dataSource = self;
        [_tableview registerNib:[UINib nibWithNibName:@"hahaTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
        
    }
    return _tableview;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 8;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    hahaTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
                               @"cell"];
    self.tableview.rowHeight = 135;
    return cell;
}

@end



#import "ONEViewController.h"
#import "CKSlideMenu.h"
#import "jinriViewController.h"
#import "yuleViewController.h"
#import "fuckViewController.h"

@interface ONEViewController ()

@end

@implementation ONEViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    NSArray *titles = @[@"今日",@"阿萨德",@"爱迪生",@"暗示",@"说的",@"粉丝",@"阿萨德",@"爱迪生",@"暗示",@"说的"];
    jinriViewController *ONE = [[jinriViewController alloc]init];
    ONE.title = @"fff";
    yuleViewController *Two = [[yuleViewController alloc]init];
    Two.title = @"bbb";
    NSArray *array = @[ONE,Two];
    NSMutableArray *arr = [NSMutableArray array];
    for (int i = 0; i <2 ; i++) {
        [arr addObject:array[i]];
        
    }
    
    CKSlideMenu *slideMenu = [[CKSlideMenu alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width-60, 40) titles:titles controllers:arr];
    slideMenu.bodyFrame = CGRectMake(0, 64+40, self.view.frame.size.width, self.view.frame.size.height-64-40);
    [slideMenu scrollToIndex:3];
    [self.view addSubview:slideMenu];
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(360, 50, 60, 64)];
    [btn setTitle:@"++++" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [self.view addSubview:btn];
    [btn addTarget:self action:@selector(abc) forControlEvents:UIControlEventAllEvents];
    
    
}
-(void)abc{
    
    fuckViewController *fuck = [[fuckViewController alloc]init];
    [self.navigationController pushViewController:fuck animated:YES];
    
    
    
    
    
}

@end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值