//
|
// IndividualStarController.m
|
// BuWanVideo2.0
|
//
|
// Created by weikou2016 on 16/8/18.
|
// Copyright © 2016年 com.yeshi.buwansheque.ios. All rights reserved.
|
//
|
|
#import "IndividualStarController.h"
|
#import "Starview.h"
|
#import "StarmovieCell.h"
|
#import "XYRDetailViewController.h"
|
|
@interface IndividualStarController ()<UITableViewDataSource,UITableViewDelegate>{
|
UITableView *tableview;
|
NSMutableDictionary *data;
|
NSMutableArray *movelist;
|
int page;
|
}
|
|
@end
|
|
@implementation IndividualStarController
|
@synthesize data;
|
|
|
- (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]};
|
|
//默认加载第一页的数据
|
page=1;
|
|
//设置背景色
|
self.view.backgroundColor = kGlobalBackgroundColor;
|
|
//返回按钮
|
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;
|
|
//明星个人资料
|
Starview * star =[Starview initwithFrame:CGRectMake(10, kNavigationBarH + 10 , self.view.frame.size.width - 20, 100) WithDic:data];
|
[self.view addSubview:star];
|
|
//计算明星简介内容需要盛放的高度
|
float IntroductionHeight = [self getHeightWithStr:star.Production.text WithWidth:KScreenW-130];
|
star.ProductionHeight.constant += IntroductionHeight;
|
if(IntroductionHeight > 15){
|
star.frame = CGRectMake(star.frame.origin.x, star.frame.origin.y, star.frame.size.width, star.frame.size.height+ IntroductionHeight-14);
|
}
|
//装载作品的视图
|
tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, star.frame.origin.y + star.frame.size.height + 10, self.view.frame.size.width, KScreenH-star.frame.origin.y - star.frame.size.height - 10) style:UITableViewStylePlain];
|
tableview.delegate =self;
|
tableview.dataSource = self;
|
tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
|
tableview.backgroundColor = kGlobalBackgroundColor;
|
[self.view addSubview:tableview];
|
|
//head
|
UIView * ui = [UIView new];
|
ui.frame = CGRectMake(0, 0, self.view.frame.size.width, 30);
|
ui.backgroundColor = kGlobalBackgroundColor;
|
|
UILabel *lb = [UILabel new];
|
lb.frame = CGRectMake(15, 0, 100, 30);
|
lb.text = @"影视列表";
|
lb.font = [UIFont systemFontOfSize:14];
|
[ui addSubview:lb];
|
tableview.tableHeaderView =ui;
|
|
//注册cell
|
[tableview registerNib:[UINib nibWithNibName:@"StarmovieCell" bundle:nil] forCellReuseIdentifier:@"StarmovieCell"];
|
tableview.mj_header=[MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
[self headupdata];
|
} ];
|
//刷新 并加载数据
|
[tableview.mj_header beginRefreshing];
|
}
|
|
/**
|
* 字符串高度计算
|
*/
|
-(float)getHeightWithStr:(NSString*)str WithWidth:(float)width{
|
UILabel *lb = [UILabel new];
|
lb.text = str;
|
lb.numberOfLines = 0;
|
lb.font = [UIFont systemFontOfSize:12];
|
CGSize size = [lb sizeThatFits:CGSizeMake(width, MAXFLOAT)];
|
return size.height - 15;
|
}
|
|
/**
|
下拉刷新
|
*/
|
-(void)headupdata{
|
page = 1;
|
[[YTHNetInterface startInterface]getHotStarsVideoWithUid:[YTHsharedManger startManger].Uid withStarId:[data objectForKey:@"Id"] withSystem:@"1" withPage:[NSString stringWithFormat:@"%d",page] withBlock:^(BOOL isSuccessful, id result, NSString *error) {
|
if(isSuccessful){
|
if (movelist==nil) {
|
movelist=[NSMutableArray arrayWithCapacity:0];
|
}else{
|
[movelist removeAllObjects];
|
}
|
|
movelist = [[result objectForKey:@"Data"]objectForKey:@"data"];
|
if (movelist.count>15) {
|
tableview.mj_footer=[MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
|
[self footupdata];
|
}];
|
}
|
++page;
|
[tableview reloadData];
|
}else{
|
NSLog(@"%@",error);
|
}
|
[tableview.mj_header endRefreshing];
|
}];
|
}
|
|
|
/**
|
* 上拉加载更多
|
*/
|
-(void)footupdata{
|
[[YTHNetInterface startInterface]getHotStarsVideoWithUid:[YTHsharedManger startManger].Uid withStarId:[data objectForKey:@"Id"] withSystem:@"1" withPage:[NSString stringWithFormat:@"%d",page] withBlock:^(BOOL isSuccessful, id result, NSString *error) {
|
if(isSuccessful){
|
NSArray *newdata = [[result objectForKey:@"Data"]objectForKey:@"data"];
|
if (newdata.count>0) {
|
if (movelist==nil) {
|
movelist=[NSMutableArray arrayWithCapacity:0];
|
}
|
if (page==1) {
|
[movelist removeAllObjects];
|
}else{
|
++page;
|
}
|
for (int i = 0 ; i < newdata.count ; ++i) {
|
[movelist addObject:[newdata objectAtIndex:i]];
|
}
|
[tableview reloadData];
|
}
|
}else{
|
NSLog(@"%@",error);
|
}
|
[tableview.mj_footer endRefreshing];
|
}];
|
|
}
|
|
#pragma mark UITableViewDataSource UITableViewDelegate
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
return movelist.count;
|
}
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
StarmovieCell * cell = [tableView dequeueReusableCellWithIdentifier:@"StarmovieCell"];
|
NSDictionary *dic = movelist[indexPath.row];
|
[cell.image setYthImageWithURL:[dic objectForKey:@"Hpicture"] placeholderImage:[UIImage imageNamed:@"默认加载图片"]];
|
cell.moviename.text = [dic objectForKey:@"Name"];
|
cell.grade.text = [NSString stringWithFormat:@"评分%@",[dic objectForKey:@"Score"]];
|
float watchnum = ((NSString*)[dic objectForKey:@"WatchCount"]).floatValue;
|
if( watchnum+0.1 > 10000){
|
cell.play.text = [NSString stringWithFormat:@"%.2f万",watchnum/10000];
|
}else{
|
cell.play.text = [dic objectForKey:@"WatchCount"];
|
}
|
|
float Commentnum = ((NSString*)[dic objectForKey:@"CommentCount"]).floatValue;
|
if( Commentnum+0.1 > 10000){
|
cell.commentnum.text = [NSString stringWithFormat:@"%.2f万",Commentnum/10000];
|
}else{
|
cell.commentnum.text = [NSString stringWithFormat:@"%.0f",Commentnum];
|
}
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
return cell;
|
}
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
return 85;
|
}
|
|
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
NSDictionary * dic = movelist[indexPath.row];
|
XYRDetailViewController *play=[[XYRDetailViewController alloc]init];
|
[YTHsharedManger startManger].preController = self;
|
play.modalPresentationStyle = 0;
|
play.Model = [XYRVideoInfoModel yy_modelWithDictionary:dic];
|
[self presentViewController:play animated:YES completion:^{
|
|
}];
|
}
|
|
/**
|
返回方法
|
*/
|
-(void)back:(UIButton*)sender{
|
[self.navigationController popViewControllerAnimated:YES];
|
}
|
@end
|