123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- //
- // SchoolNewsVC.m
- // jiaPei
- //
- // Created by apple on 16/1/27.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "SchoolNewsVC.h"
- #import "NewsDetVC.h"
- #import "HolderView.h"
- @interface SchoolNewsVC ()<UITableViewDataSource,UITableViewDelegate>
- {
- NSArray *newsArray;
- UITableView *mainTable;
- HolderView* holdV;
- }
- @end
- @implementation SchoolNewsVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title = @"驾校新闻";
- self.view.backgroundColor = backGroundColor;
- [self configNavigationBar];
-
- newsArray = [NSArray array];
- [self getnewsList];
- [self myInit];
- }
- -(void)myInit
- {
- mainTable = [[UITableView alloc] initWithFrame:kFrame];
- mainTable.height -= kNavOffSet;
- mainTable.delegate = self;
- mainTable.dataSource = self;
- mainTable.estimatedSectionFooterHeight = 0;
- [self.view addSubview:mainTable];
-
- holdV = [[HolderView alloc] initWithFrame:mainTable.frame];
- [holdV freshBlock:^{
- [self getnewsList];
- }];
- [self.view addSubview:holdV];
- [holdV setHidden:YES];
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return newsArray.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
- if (cell == nil)
- {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
- }
-
- NSDictionary *dic = newsArray[indexPath.row];
-
- cell.textLabel.text = [NSString stringWithFormat:@"%d、%@ %@",(int)indexPath.row + 1,dic[@"GROUPNAME"],dic[@"TITLE"]];
-
- NSString *string = [NSString stringWithFormat:@"%d、%@ %@",(int)indexPath.row + 1,dic[@"GROUPNAME"],dic[@"TITLE"]];
- NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%d、%@ %@",(int)indexPath.row + 1,dic[@"GROUPNAME"],dic[@"TITLE"]]];
-
- NSRange sub = [string rangeOfString:@" "];
- [str addAttribute:NSForegroundColorAttributeName value:defGreen range:NSMakeRange(0,sub.location)];
- cell.textLabel.attributedText = str;
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NewsDetVC* vc = [[NewsDetVC alloc] init];
- [vc setPreModel:newsArray[indexPath.row]];
- vc.type = @"2";
- [self navPushHideTabbarToVC:vc];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- {
- return .1;
- }
- -(void)getnewsList
- {
- [holdV setHidden:0];
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:self.jxbh,@"jxbh", nil]];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"" ,@"isPage", nil]];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"" ,@"pageSize", nil]];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"" ,@"currentPage", nil]];
- //NSLog(@"新闻--%@",arr);驾校新闻 应该做个分页的 但是这里不想 等后期数据够多再加 dansonmark
- NSString* method = @"getNewsInfoByJxbh";
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- [MBProgressHUD hideHUDForView:self.view];
- if (!root)
- {
- ShowMsgFailed();
- return;
- }
- NSString* code = root[@"code"];
- if ( 1 == code.intValue ) {
- ShowMsgFailed();
- return;
- }
- NSArray* news = root[@"body"];
- //NSLog(@"获取到的新闻列表---->%@",news);
- newsArray = news;
- [holdV setHidden:newsArray.count];
- [mainTable reloadData];
- }];
-
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|