88 lines
3.6 KiB
Mathematica
88 lines
3.6 KiB
Mathematica
|
|
//
|
||
|
|
// QXHotRoomViewController.m
|
||
|
|
// QXLive
|
||
|
|
//
|
||
|
|
// Created by 启星 on 2025/10/21.
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "QXHotRoomViewController.h"
|
||
|
|
#import "QXHomeRoomCell.h"
|
||
|
|
@interface QXHotRoomViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
|
||
|
|
@property (nonatomic,strong)UICollectionView *collectionView;
|
||
|
|
|
||
|
|
@end
|
||
|
|
|
||
|
|
@implementation QXHotRoomViewController
|
||
|
|
|
||
|
|
- (void)viewDidLoad {
|
||
|
|
[super viewDidLoad];
|
||
|
|
// Do any additional setup after loading the view.
|
||
|
|
}
|
||
|
|
-(void)setNavgationItems{
|
||
|
|
[super setNavgationItems];
|
||
|
|
self.navigationItem.title = @"热门房间";
|
||
|
|
}
|
||
|
|
-(void)viewWillAppear:(BOOL)animated{
|
||
|
|
[super viewWillAppear:animated];
|
||
|
|
[self.navigationController setNavigationBarHidden:NO animated:YES];
|
||
|
|
}
|
||
|
|
-(void)initSubViews{
|
||
|
|
[self.view addSubview:self.collectionView];
|
||
|
|
}
|
||
|
|
#pragma mark - UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout
|
||
|
|
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||
|
|
return self.list.count;
|
||
|
|
}
|
||
|
|
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
|
QXHomeRoomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXHomeRoomCell" forIndexPath:indexPath];
|
||
|
|
cell.model = self.list[indexPath.row];
|
||
|
|
return cell;
|
||
|
|
}
|
||
|
|
-(void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
|
QXHomeRoomCell *roomCell = (QXHomeRoomCell *)cell;
|
||
|
|
[roomCell startAnimating];
|
||
|
|
}
|
||
|
|
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
|
QXHomeRoomCell *roomCell = (QXHomeRoomCell *)cell;
|
||
|
|
[roomCell endAnimating];
|
||
|
|
}
|
||
|
|
|
||
|
|
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
|
return CGSizeMake((SCREEN_WIDTH-15*3-1)/2.0, (SCREEN_WIDTH-15*3-1)/2.0);
|
||
|
|
}
|
||
|
|
|
||
|
|
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
|
QXRoomListModel *model = self.list[indexPath.row];
|
||
|
|
[[QXGlobal shareGlobal] joinRoomWithRoomId:model.room_id isRejoin:NO navagationController:self.navigationController];
|
||
|
|
|
||
|
|
}
|
||
|
|
-(UICollectionView *)collectionView{
|
||
|
|
if (!_collectionView) {
|
||
|
|
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||
|
|
layout.minimumLineSpacing = 15;
|
||
|
|
layout.minimumInteritemSpacing = 15;
|
||
|
|
layout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15);
|
||
|
|
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 16, SCREEN_WIDTH, SCREEN_HEIGHT-NavContentHeight) collectionViewLayout:layout];
|
||
|
|
_collectionView.delegate = self;
|
||
|
|
_collectionView.dataSource = self;
|
||
|
|
_collectionView.bounces = YES;
|
||
|
|
_collectionView.backgroundColor = [UIColor clearColor];
|
||
|
|
[_collectionView registerNib:[UINib nibWithNibName:@"QXHomeRoomCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"QXHomeRoomCell"];
|
||
|
|
}
|
||
|
|
return _collectionView;
|
||
|
|
}
|
||
|
|
/*
|
||
|
|
#pragma mark - Navigation
|
||
|
|
|
||
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||
|
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||
|
|
// Get the new view controller using [segue destinationViewController].
|
||
|
|
// Pass the selected object to the new view controller.
|
||
|
|
}
|
||
|
|
*/
|
||
|
|
|
||
|
|
@end
|