#import "ViewController.h"#import "define.h"#import "HotCollectCollectionViewCell.h"#import "JIexiModel.h"#import "AFNetworking.h"#import "TowTZViewController.h"@interface ViewController ()@property(nonatomic,strong)UICollectionView *collectionView;
@property(nonatomic,strong)NSMutableArray *mutablearray;
@end
@implementation ViewController
-(void)collectongview{
? ? UICollectionViewFlowLayout *flowlayout = [[UICollectionViewFlowLayout alloc]init];
? ? flowlayout.itemSize = CGSizeMake((SCREEN_WIDTH)/2.0, (SCREEN_WIDTH - 30)/2.0 *4/5);
//堅直滑動
? ? flowlayout.scrollDirection = UICollectionViewScrollDirectionVertical;
? ? //設(shè)置垂直方向的空隙
flowlayout.minimumLineSpacing=5;
//設(shè)置水平方向的空隙
flowlayout.minimumInteritemSpacing =? 0;
? ? // 實列化
? ? _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64 - 49)collectionViewLayout:flowlayout];
? ? _collectionView.backgroundColor = [UIColor whiteColor];
? ? _collectionView.delegate = self;
? ? _collectionView.dataSource = self;
? ? _collectionView.tag = 10000;
? ? [self.view addSubview:_collectionView];
? ? //注冊cell類
? ? [_collectionView registerClass:[HotCollectCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
? ? [self.view addSubview:_collectionView];
}
- (void)viewDidLoad {
? ? [super viewDidLoad];
? ? self.title = @"推薦";
? ? self.view.backgroundColor = [UIColor lightGrayColor];
? ? [self collectongview];
? ? //獲取鏈接
? ? NSString *urlString = @"http://123.126.40.109:7003/asmr/videos/A1100101.shtml";
? ? //解析網(wǎng)絡(luò)數(shù)據(jù)
? [JIexiModel httpGet:urlString parameters:nil reuslt:^(NSDictionary *reuslt) {
? ? ? //將data里面的數(shù)據(jù)賦給NSArray
? ? ? NSArray *arr = reuslt[@"result"];
? ? ? _mutablearray = [[NSMutableArray alloc]i