//
|
// AllSpecialController.m
|
// BuWanVideo2.0
|
//
|
// Created by weikou2016 on 16/8/19.
|
// Copyright © 2016年 com.yeshi.buwansheque.ios. All rights reserved.
|
//
|
|
#import "AllSpecialController.h"
|
#import "AllSpecialCell.h"
|
#import "OnlySpecialController.h"
|
|
@interface AllSpecialController ()<UITableViewDelegate,UITableViewDataSource>{
|
UITableView * tableview;
|
NSMutableArray * arrdata;
|
int page;
|
}
|
|
@end
|
|
@implementation AllSpecialController
|
|
- (void)viewDidLoad {
|
[super viewDidLoad];
|
//[MobClick beginLogPageView:@"进入专题合集"];
|
|
[self initScene];
|
}
|
|
-(void)dealloc{
|
//[MobClick beginLogPageView:@"退出专题合集"];
|
}
|
|
-(void)initScene{
|
self.navigationItem.title = @"专题合集";
|
|
self.navigationController.navigationBar.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]};;
|
|
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
[button setImage:[[UIImage imageNamed:@"详情页面返回"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
|
[button addTarget:self action:@selector(back:)
|
forControlEvents:UIControlEventTouchUpInside];
|
button.frame = CGRectMake(0, 0, 32, 32);
|
UIBarButtonItem *iconBarItem=[[UIBarButtonItem alloc] initWithCustomView:button];
|
self.navigationItem.leftBarButtonItem = iconBarItem;
|
|
self.view.backgroundColor = kGlobalBackgroundColor;
|
|
arrdata = [NSMutableArray arrayWithCapacity:0];
|
tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
|
tableview.delegate = self;
|
tableview.dataSource = self;
|
tableview.backgroundColor = kGlobalBackgroundColor;
|
tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
|
[self.view addSubview:tableview];
|
|
[tableview registerNib:[UINib nibWithNibName:@"AllSpecialCell" bundle:nil] forCellReuseIdentifier:@"AllSpecialCell"];
|
tableview.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headupdata)];
|
[tableview.mj_header beginRefreshing];
|
|
}
|
|
-(void)headupdata{
|
[[YTHNetInterface startInterface]getFoundSpecialList:[YTHsharedManger startManger].Uid withPage:@"1" WithSystem:@"1" WithBlock:^(BOOL isSuccessful, id result, NSString *error) {
|
if(isSuccessful){
|
arrdata = [[result objectForKey:@"Data"] objectForKey:@"data"];
|
if (arrdata.count > 0) {
|
++page;
|
[tableview reloadData];
|
}
|
if (arrdata.count >5) {
|
tableview.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footupdata)];
|
}
|
}else{
|
|
NSLog(@"%@",error);
|
}
|
[tableview.mj_header endRefreshing];
|
}];
|
|
}
|
|
-(void)footupdata{
|
[[YTHNetInterface startInterface]getFoundSpecialList:[YTHsharedManger startManger].Uid withPage:[NSString stringWithFormat:@"%d",page] WithSystem:@"1" WithBlock:^(BOOL isSuccessful, id result, NSString *error) {
|
if(isSuccessful){
|
NSArray *newarr = [[result objectForKey:@"Data"] objectForKey:@"data"];
|
if (arrdata!=nil) {
|
[arrdata removeAllObjects];
|
}else{
|
arrdata=[NSMutableArray arrayWithCapacity:0];
|
}
|
if(newarr.count >0){
|
[arrdata addObjectsFromArray:newarr];
|
[tableview reloadData];
|
++page;
|
}
|
}else{
|
NSLog(@"%@",error);
|
}
|
[tableview.mj_footer endRefreshing];
|
}];
|
}
|
|
|
#pragma mark UITableViewDelegate UITableViewDataSource
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
return arrdata.count;
|
}
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
AllSpecialCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AllSpecialCell" forIndexPath:indexPath];
|
NSDictionary *dic = arrdata[indexPath.row];
|
[cell.image setYthImageWithURL:[dic objectForKey:@"Picture"] placeholderImage:[UIImage imageNamed:@"默认加载图片"]];
|
cell.lable.text = [dic objectForKey:@"Name"];
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
return cell;
|
}
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
return KScreenW/16*7+40;
|
}
|
|
-(void)back:(UIButton*)sender{
|
[self.navigationController popViewControllerAnimated:YES];
|
}
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
OnlySpecialController * oscontroller = [OnlySpecialController new];
|
oscontroller.Id = ((NSString*)[arrdata[indexPath.row] objectForKey:@"Id"]).intValue;
|
[self.navigationController pushViewController:oscontroller animated:YES];
|
}
|
|
|
|
@end
|