注册

测拉菜单的demo,加上个点开菜单后对应不同类型的商品信息

 self.view.backgroundColor=[UIColor whiteColor];

    self.navigationController.navigationBar.barTintColor = NavColor;




    self.navigationItem.title = @"主页";




    self.navigationController.navigationBar.translucent = YES;

    

    GoodsImage = [NSMutableArray array];

    PhoneArray = [NSMutableArray array];

    ComputerArray = [NSMutableArray array];

    LifeGoodsArray = [NSMutableArray array];

    qitaArray = [NSMutableArray array];

    

    UIButton *menuBtn = [UIButton buttonWithType:UIButtonTypeCustom];

    menuBtn.frame = CGRectMake(0,0,30,40);

    //[menuBtn setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];

    [menuBtn setBackgroundImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];

    [menuBtn addTarget:self action:@selector(openOrCloseLeftList) forControlEvents:UIControlEventTouchUpInside];

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:menuBtn];

    SpeciesArray=@[@"手机数码",@"家具家电",@"日用百货",@"其他二手"];

   

    //左侧是tableview显示页面

    TableView = [[UITableView alloc]initWithFrame:CGRect1(0, 0, 120, 667-104) style:UITableViewStylePlain];

    TableView.delegate = self;

    TableView.dataSource = self;

    TableView.separatorStyle = UITableViewCellSeparatorStyleNone;

    TableView.rowHeight = 70*SCALE1;

    [self.view addSubview:TableView];

    
 

    //右边是对应的collection对应的显示页面

    collection = [[UICollectionView alloc]initWithFrame:CGRect1(130, 80, 205, 563) collectionViewLayout:[[UICollectionViewFlowLayout alloc]init]];

    [collection registerClass:[MyCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];

    collection.dataSource = self;

    collection.delegate  = self;

    collection.backgroundColor = [UIColor whiteColor];

    [self.view addSubview:collection];

    




}

//测拉菜单的实现开启

- (void) openOrCloseLeftList

{

    

    AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

    

    if (tempAppDelegate.leftslidevc.closed)

    {

        [tempAppDelegate.leftslidevc openLeftView];

    }

    else

    {

        [tempAppDelegate.leftslidevc closeLeftView];

    }

}




/************tableView行数************/

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

    return SpeciesArray.count;

}

/************tableViewcell添加*********************/

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

{

    static NSString *inder = @"cell";

    MainPageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:inder];

    if (cell ==nil) {

        cell = [[MainPageTableViewCell alloc]initWithStyle:1 reuseIdentifier:inder];

    }

    cell.textLabel.text=SpeciesArray[indexPath.row];

   

    return  cell;

}

/****************tableview选中*********************/

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

    // [tableView deselectRowAtIndexPath:indexPath animated:YES];

    if (indexPath.row ==0)

    {

        self.navigationItem.title = @"手机数码";

        GoodsImage =[NSMutableArray arrayWithObjects:@"苹果皮",@"三星",@"华为",nil];

        

        [collection reloadData];

    }

    if (indexPath.row ==1)

    {

        self.navigationItem.title = @"家具家电";

        GoodsImage = [NSMutableArray arrayWithObjects:@"电视",@"冰箱" ,nil];

        [collection reloadData];

    }

    if (indexPath.row ==2)

    {

        self.navigationItem.title = @"日用百货";

        GoodsImage = [NSMutableArray arrayWithObjects:@"毛巾",@"脸盆" ,nil];

        [collection reloadData];

            }

    if (indexPath.row ==3)

    {

        self.navigationItem.title = @"其他二手";

        GoodsImage = [NSMutableArray arrayWithObjects:@"牙刷",@"奔驰" ,nil];

        [collection reloadData];

        

    }

    

}



  • 屏幕快照_2016-03-25_下午5.54_.07_.png



    屏幕快照_2016-03-25_下午5.54_.17_.png



2 个评论

蜗牛棒棒哒!赞一个
没有收到您的赞赏哦!!哈哈哈

要回复文章请先登录注册