热更新demo

notificationController.m 5.5KB

    // // notificationController.m // ThePaperBase // // Created by YoungLee on 15/8/17. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "notificationController.h" #import "messageViewModel.h" #import "notificationCell.h" #import "pushMsgController.h" #import "myAskController.h" #import "myFocusController.h" #import "myAnswerController.h" #import "myDynamicController.h" @interface notificationController ()<messageViewModelDelegate>{ NSMutableDictionary *msgDic; } @property(nonatomic, strong)NSArray *dataList; @property(nonatomic, strong)messageViewModel *model; @end @implementation notificationController static NSString *notificationCellID = @"notificationCellID"; - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; _dataList = @[@[@"我的提问",@"关注的提问",@"回复我的"],@[@"推送消息"],@[@"我的动态"]]; // self.tableView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; self.tableView.scrollEnabled = NO; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; [self.tableView registerClass:[notificationCell class] forCellReuseIdentifier:notificationCellID]; self.model = messageViewModel.new; self.model.delegate = self; self.model.msgMark = nil; //推送消息:从推送消息列表进入一篇新闻后切换成夜间模式后返回,推送列表页及我的消息页显示异常(bug:5844) [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil]; // Do any additional setup after loading the view. } - (void)needrefreshNightMode:(id)sender{ self.view.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; [self.tableView reloadData]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; if(![TPUserDefault instance].userBO){ [self.navigationController popToRootViewControllerAnimated:NO]; } } #pragma mark -- tableView - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return _dataList.count; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return ((NSArray*)_dataList[section]).count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 50.0; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 10; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ UIView *view = [[UIView alloc]init]; view.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; return view; } - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { notificationCell *cell = [tableView dequeueReusableCellWithIdentifier:notificationCellID]; if (nil == cell) { cell = [[notificationCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:notificationCellID]; } cell.topic = _dataList[indexPath.section][indexPath.row]; cell.indexPath = indexPath; cell.msgDic = msgDic; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [[UIApplication sharedApplication]beginIgnoringInteractionEvents]; [tableView deselectRowAtIndexPath:indexPath animated:NO]; //我的消息,通知tab,点击下方菜单时需要点击效果,包括夜间模式(bug:5236) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ if (0 ==indexPath.section) { if(0 == indexPath.row){ myAskController *vc = [myAskController new]; [self.navigationController pushViewController:vc animated:YES]; }else if(1 == indexPath.row){ myFocusController *vc = [myFocusController new]; [self.navigationController pushViewController:vc animated:YES]; }else if (2 == indexPath.row){ myAnswerController *vc = [myAnswerController new]; [self.navigationController pushViewController:vc animated:YES]; } }else if (1 == indexPath.section){ [MobClick event:@"82"]; [self.navigationController pushViewController:[pushMsgController new] animated:YES]; }else if (2 == indexPath.section){ myDynamicController *myDynamicVC = [myDynamicController new]; commentObjectVO *comment = commentObjectVO.new; comment.userInfo = setDataModelToDic([TPUserDefault instance].userBO, [userBO class]); myDynamicVC.comment = comment; myDynamicVC.isMsgController = YES; [self.navigationController pushViewController:myDynamicVC animated:YES]; } [[UIApplication sharedApplication]endIgnoringInteractionEvents]; }); } -(void)viewWillLayoutSubviews{ [super viewWillLayoutSubviews]; } -(void)returnMsgMark:(NSMutableDictionary *)dic{ //我的消息:点击有红点的二级菜单,红点应立即消失,而不是从二级菜单返回后再消失(bug:5458) if ([self.delegate respondsToSelector:@selector(appearMsgMark:)]) { [self.delegate appearMsgMark:dic]; } msgDic = [NSMutableDictionary dictionaryWithDictionary:dic]; [self.tableView reloadData]; } @end