热更新demo

topicCollectionController.m 4.0KB

    // // topicCollectionController.m // ThePaperBase // // Created by Huixin on 15/10/12. // Copyright © 2015年 scar1900. All rights reserved. // #import "topicCollectionController.h" #import "topicCollectionListController.h" #import "topicContentController.h" @interface topicCollectionController () <topicCollectionListDelegate> @property(nonatomic, strong)topicCollectionListController *vc; @end @implementation topicCollectionController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode) name:REFRESHAFTERNIGHTMODE object:nil]; [self.view addSubview:self.vc.view]; [self addChildViewController:self.vc]; [self.vc didMoveToParentViewController:self]; self.titleStr = self.name; CGFloat labelWidth = [self.titleLabel sizeThatFits:CGSizeMake(0, 25)].width; if (labelWidth > CGRectGetWidth(self.naviBar.bounds)-115) { //bug5882: 【适配性】话题合集:224下iphone4,5系列话题合集标题显示不全 if (labelWidth > CGRectGetWidth(self.naviBar.bounds)-80) self.titleLabel.frame = CGRectMake(40, CGRectGetMaxY(self.naviBar.bounds)-35, CGRectGetWidth(self.naviBar.bounds)-40, 25); else self.titleLabel.frame = CGRectMake(40, CGRectGetMaxY(self.naviBar.bounds)-35, CGRectGetWidth(self.naviBar.bounds)-80, 25); } [self.vc.view makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.naviBar.bottom); make.left.equalTo(self.view.left); make.right.equalTo(self.view.right); make.bottom.equalTo(self.view.bottom); }]; [self remoteAction]; // Do any additional setup after loading the view. } - (void)needrefreshNightMode { self.view.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; } #pragma mark - get and set method - (topicCollectionListController*)vc { if (!_vc) { _vc = [topicCollectionListController new]; _vc.delegate = self; } return _vc; } - (void)remoteAction { NSDictionary *dic = @{@"n":_nodeId}; [Remote doJsonAction:1 requestUrl:topicSpecURL parameter:dic delegate:self]; } #pragma mark - remote delegate -(void)remoteResponsSuccess:(int)actionTag withResponsData:(id)responsData{ specialObjectBO *specialBO = setJsonDicToDataModel(responsData[@"specialInfo"], [specialObjectBO class]); if (isBlankString(self.titleStr)) { self.titleStr = specialBO.name; } NSArray *list = responsData[@"topicList"]; NSMutableArray *temp = [NSMutableArray array]; [temp addObject:specialBO.desc]; [list enumerateObjectsUsingBlock:^(NSDictionary *dic, NSUInteger idx, BOOL *stop) { if (![dic[@"forwordType"] isEqualToString:@"4"]) { TopicInfoBO *bo = setJsonDicToDataModel(dic, [TopicInfoBO class]); bo.isFirstCard = @"0"; [temp addObject:bo]; } }]; self.vc.dataList = temp; self.vc.nextUrl = responsData[@"nextUrl"]; } #pragma mark - topicCollectionListDelegate - (void)gotoInfo:(TopicInfoBO *)topicBO{ topicContentController *topicVC = [topicContentController new]; topicVC.preTopicInfo = topicBO; [self.navigationController pushViewController:topicVC animated:YES]; } #pragma mark - navibar - (void)tapNaviBar:(id)sender { [self.vc.tableView setContentOffset:CGPointZero animated:YES]; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #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