热更新demo

myDynamicController.m 7.3KB

    // // myDynamicController.m // ThePaperBase // // Created by YoungLee on 15/8/31. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "myDynamicController.h" #import "myDynamicTableController.h" #import "writeCommentAndAskController.h" #import "askDetailController.h" #import "topicDeatilController.h" #import "userInfoController.h" #import "imageShareContent.h" @interface myDynamicController ()<myDynamicTableDelegate,writeContentDelegate> @property(nonatomic, strong)myDynamicTableController *dynamicTableVC; @property(nonatomic, strong)writeCommentAndAskController *writeCommentContentVC; @property(nonatomic, strong) UILabel *topicLabel; @end @implementation myDynamicController @synthesize comment = _comment; @synthesize isMsgController = _isMsgController; - (void)viewDidLoad { [super viewDidLoad]; [MobClick event:@"58"]; self.dynamicTableVC = [myDynamicTableController new]; self.dynamicTableVC.commentBo = _comment; self.dynamicTableVC.delegate = self; [self addChildViewController:self.dynamicTableVC]; [self.view addSubview:self.dynamicTableVC.view]; [self.dynamicTableVC.view makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view.left); make.right.equalTo(self.view.right); make.top.equalTo(self.barHeight); make.bottom.equalTo(self.view.bottom); }]; [self.view addSubview:self.topicLabel]; self.topicLabel.alpha = 0.0f; //个人动态,昵称上移后太长显示不全(bug:5147) [self.topicLabel makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.naviBar.left).offset(35); make.right.equalTo(self.naviBar.right).offset(-35); make.top.equalTo(self.naviBar.top).offset(20); make.bottom.equalTo(self.naviBar.bottom); }]; // Do any additional setup after loading the view. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil]; } - (void)needrefreshNightMode:(id)sender{ self.dynamicTableVC.view.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; self.topicLabel.backgroundColor = [UIColor clearColor]; self.topicLabel.textColor = [UIColor colorWithHexString:TextBlack]; self.dynamicTableVC.tableView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; } -(void)setIsMsgController:(BOOL)isMsg{ _isMsgController = isMsg; } -(void)setComment:(commentObjectVO *)commentBO{ _comment = commentBO; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)tapNaviBar:(id)sender { [self.dynamicTableVC scrollTableViewToTop]; } -(UILabel *)topicLabel{ if (!_topicLabel) { _topicLabel = [UILabel new]; _topicLabel.textColor = [UIColor colorWithHexString:TextBlack]; _topicLabel.backgroundColor = [UIColor clearColor]; _topicLabel.font = appFont(TEXT_THREE_LEVELSIZE, NO); _topicLabel.textAlignment = NSTextAlignmentCenter; _topicLabel.alpha = 0.0f; } return _topicLabel; } #pragma mark -- table delegate -(void)gotoLogin:(userBO *)user{ userInfoController *userInfo = [userInfoController new]; [self.navigationController pushViewController:userInfo animated:YES]; } #pragma mark -- 上推效果 -(void)setLabel:(CGPoint)contentOffset name:(NSString *)name{// 个人动态页,上推名字到顶部的渐变效果需要按照移动距离(bug:5221) self.topicLabel.text = name; if (contentOffset.y <70) { self.topicLabel.alpha = 0.0f; }else if (contentOffset.y >=70 && contentOffset.y<100) { CGFloat alpha = (contentOffset.y-70)/30; self.topicLabel.alpha = alpha; }else if (contentOffset.y >100) { self.topicLabel.alpha = 1.0f; } } #pragma mark -- bank handler - (void)backHandler { //个人动态:如此操作退出登录后我的消息页没有消失(bug:6061) if (![TPUserDefault instance].userBO && self.isMsgController) { [self.navigationController popToRootViewControllerAnimated:YES]; }else{ [self.navigationController popViewControllerAnimated:YES]; } } #pragma mark -- goto other controller -(void)gotoAskInfo:(commentObjectVO *)comment{ if ([comment.objectType intValue] == 3) {//话题问答详情页 topicDeatilController *topic = [[topicDeatilController alloc] init]; topic.commentBO = comment; TopicInfoBO *topicBO = [TopicInfoBO new]; topicBO.topicId = comment.contId; topic.topicInfo = topicBO; [self.navigationController pushViewController:topic animated:YES]; }else{//新闻问答详情页 askDetailController *askDetailVC = [[askDetailController alloc] init]; askDetailVC.commentBO = comment; [self.navigationController pushViewController:askDetailVC animated:YES]; } } -(void)gotoDetail:(id)data{ pushContentWithCommentBO(self.navigationController, data); } -(void)gotoCommentWith:(commentObjectVO *)comment{ self.writeCommentContentVC = [[writeCommentAndAskController alloc]init]; if ([comment.type intValue] == 1) { self.writeCommentContentVC.type = commentForUserType; }else { self.writeCommentContentVC.type = askForUserType; } self.writeCommentContentVC.nodeId = comment.contId; self.writeCommentContentVC.delegate = self; self.writeCommentContentVC.commentBO = comment; if([comment.objectType isEqualToString:@"3"]){//0004269: 个人主页: 通过头像进入个人主页,对列表中的评论、话题的提问进行回复时提示不存在或下线的提示信息(bug:4269) self.writeCommentContentVC.commentOT = @"3"; } [self presentController:self.writeCommentContentVC animated:YES completion:^{ }]; } - (void)dismissWriteContent:(commentAndAskType)type{ __weak typeof(self) Self = self; [self dismissViewController:self.writeCommentContentVC animated:YES completion:^{ Self.writeCommentContentVC = nil; }]; } - (void)commentSuccess:(commentAndAskType)type { __weak typeof(self) Self = self; [self dismissViewController:self.writeCommentContentVC animated:YES completion:^{ Self.writeCommentContentVC = nil; [Self.dynamicTableVC manualRefresh]; }]; } -(void)gotoShare:(UIImage *)img contentBO:(contentObjectBO *)contentBO{ imageShareContent *dynamicShareContentView = [[imageShareContent alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds))]; dynamicShareContentView.contentBO = contentBO; dynamicShareContentView.shareImg = img; dynamicShareContentView.baseController = self; dynamicShareContentView.sharestyle = shareNewsStyle; [dynamicShareContentView presentShareContentInView:self.view sender:nil]; } //-(void)backHandler{ // ((MLNavigationController *)self.navigationController).canDragBack = YES; // // if (!self.isPresent) { // [self.navigationController popViewControllerAnimated:YES]; // }else { // [self dismissViewControllerAnimated:YES completion:^{ // // }]; // } //} @end