澎湃iPad上线版本

topicContentController.m 31KB

    // // topicContentController.m // ThePaperHD // // Created by scar1900 on 15/5/10. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "topicContentController.h" #import "AsyncImageView.h" #import "topicContentTableController.h" #import "otherPersonHomepageController.h" #import "customFlowLayout.h" #import "topicListController.h" #import "toolBarBtnView.h" #import "TPSelectButton.h" #import "shareButton.h" #import "TPShareContentControlelr.h" #import "loginPopUpController.h" #import "writeCommentAndAskController.h" #import "topicListHomeController.h" @interface topicContentController () <shareContentControllerDelegate,topicTableDelegate,writeContentDelegate>{ CGFloat topPadding; } @property(nonatomic, strong)AsyncImageView *headImageView; @property(nonatomic, strong)UIButton *headBtn; @property(nonatomic, strong)UIImageView *vImg; @property(nonatomic, strong)UILabel *userNameLabel; @property(nonatomic, strong)UILabel *userLine; @property(nonatomic, strong)UILabel *userDescLabel; @property(nonatomic, strong)TopicInfoBO *topicInfo; @property(nonatomic, strong)topicContentTableController *tableVC; @property(nonatomic, strong)UIView *topicView; @property(nonatomic, strong)toolBarBtnView *askButton; @property(nonatomic, strong)TPSelectButton *openAskButton; @property(nonatomic, strong)TPSelectButton *praiseButton; @property(nonatomic, strong)shareButton *shareBtn; @property(nonatomic, strong)TPShareContentControlelr *shareVC; @property(nonatomic, strong)writeCommentAndAskController *writeCommentContentVC; @end @implementation topicContentController @synthesize preTopicInfo = _preTopicInfo; @synthesize creatUser; @synthesize isCreatPage; @synthesize shareVC; @synthesize topicInfo = _topicInfo; @synthesize currentIndex; - (void)viewDidLoad { [super viewDidLoad]; [MobClick event:@"32"]; // Do any additional setup after loading the view. if (isIOS7) { topPadding = 64; }else topPadding = 44; [self enablePopBackGesture]; [self leftIconButton:@"Button/backBarBtn.png" highlited:nil selector:@selector(backButtonHandler:)]; NSString *forWardType = @""; if (self.creatUser.sname) { if ([TPUserDefault instance].userBO && [[TPUserDefault instance].userBO.userId intValue] == [self.creatUser.userId intValue]) { forWardType = @"6"; isCreatPage = YES; }else { forWardType = @"5"; isCreatPage = NO; } [self setUserInfo]; }else { if (isCreatPage) { forWardType = @"6"; }else { forWardType = @"5"; } } self.tableVC = [[topicContentTableController alloc]init]; self.tableVC.topicInfo = self.preTopicInfo; self.tableVC.isCreat = isCreatPage; self.tableVC.topicTableDelegate = self; self.tableVC.currentIndex = self.currentIndex; self.tableVC.view.frame = CGRectMake(130, topPadding, CGRectGetWidth(self.view.bounds)-130, CGRectGetHeight(self.view.bounds)-topPadding); [self addChildViewController:self.tableVC]; [self.view addSubview:self.tableVC.view]; NSDictionary *dic = @{@"topicId":self.preTopicInfo.topicId,@"forwordType":forWardType}; [Remote doJsonAction:0 requestUrl:topicInfoURL parameter:dic delegate:self]; } - (void)setPreTopicInfo:(TopicInfoBO *)data { _preTopicInfo = data; } - (void)setTopicInfo:(TopicInfoBO *)data { _topicInfo = data; userBO *user = setJsonDicToDataModel(data.userInfo, [userBO class]); if (!self.creatUser) { self.creatUser = user; if ([[TPUserDefault instance].userBO.userId intValue] == [self.creatUser.userId intValue]) { isCreatPage = YES; }else { isCreatPage = NO; } [self setUserInfo]; }else { self.creatUser = user; if ([[TPUserDefault instance].userBO.userId intValue] == [self.creatUser.userId intValue]) { isCreatPage = YES; }else { isCreatPage = NO; } [self layoutUserInfoView]; } } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.title = @"话题"; self.navigationController.navigationBarHidden = NO; if (isIOS7) { self.automaticallyAdjustsScrollViewInsets = NO; } self.navigationController.navigationBar.translucent = YES; NSString *barColor; for (int i = 0 ; i < [TPUserDefault instance].channldataList.count; i++) { if ([[TPUserDefault instance].channldataList[i][@"nodeId"] isEqualToString:@"-3"]) { barColor =[TPUserDefault instance].channldataList[i][@"color"]; } } if (isIOS7) { self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:barColor]; }else { self.navigationController.navigationBar.tintColor = [UIColor colorWithHexString:barColor]; } // if (isIOS7) { // self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"0xa89271"]; // }else { // self.navigationController.navigationBar.tintColor = [UIColor colorWithHexString:@"0xa89271"]; // } if (_topicView) { [self.topicView removeFromSuperview]; } [self.navigationController.navigationBar addSubview:self.topicView]; if (self.shareVC) { self.shareVC.startPoint = CGPointMake(5, CGRectGetHeight(self.view.bounds)-77); if (isNotIOS7) { self.shareVC.startPoint = CGPointMake(5, CGRectGetHeight(self.view.bounds)-97); } } } - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; self.shareBtn.frame = CGRectMake(CGRectGetMinX(self.headImageView.frame)+ CGRectGetWidth(self.headImageView.bounds)/2 - 72/2, CGRectGetHeight(self.view.bounds)-77, 72, 72); self.topicView.frame = CGRectMake(CGRectGetWidth(self.view.bounds)-70, 0, 70, CGRectGetHeight(self.navigationController.navigationBar.bounds)); } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self.topicView removeFromSuperview]; } - (void)setUserInfo { [self.view addSubview:self.headImageView]; self.headImageView.frame = CGRectMake(35, 20+topPadding, 60, 60); self.headBtn.frame = self.headImageView.frame; [self.view addSubview:self.headBtn]; [self.view addSubview:self.vImg]; CGFloat userNameWidth = widthForString(self.creatUser.sname, self.userNameLabel.font, 22, self.userNameLabel.lineBreakMode); CGFloat userNameHeight = 22; if (userNameWidth > 90) { userNameWidth = 90; userNameHeight = heightForString(self.creatUser.sname, self.userNameLabel.font, userNameWidth, self.userNameLabel.lineBreakMode); } [self.view addSubview:self.userNameLabel]; self.userNameLabel.frame = CGRectMake(65-userNameWidth/2, CGRectGetMaxY(self.headImageView.frame)+12, userNameWidth, userNameHeight); self.headImageView.imageUrl = self.creatUser.pic; if ([self.creatUser.isAuth intValue] == 1) { self.vImg.hidden = NO; }else { self.vImg.hidden = YES; } self.userNameLabel.text = self.creatUser.sname; CGFloat userDescHeight = heightForString(self.creatUser.perDesc, appFont(15, NO), 190/2, NSLineBreakByWordWrapping); self.userDescLabel.text = self.creatUser.perDesc; self.userDescLabel.frame = CGRectMake(17, CGRectGetMaxY(self.userNameLabel.frame)+17, 190/2, userDescHeight); [self.view addSubview:self.userDescLabel]; UIView *line = [[UIView alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(self.userNameLabel.frame)+9, 100, 1)]; line.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; [self.view addSubview:line]; [self.view addSubview:self.askButton]; [self.view addSubview:self.openAskButton]; if (isCreatPage) { self.openAskButton.hidden = NO; self.askButton.hidden = YES; }else { self.openAskButton.hidden = YES; self.askButton.hidden = NO; } [self.view addSubview:self.praiseButton]; [self.view addSubview:self.shareBtn]; } - (void)layoutUserInfoView { self.headImageView.frame = CGRectMake(35, 20+topPadding, 60, 60); self.headBtn.frame = self.headImageView.frame; CGFloat userNameWidth = widthForString(self.creatUser.sname, self.userNameLabel.font, 22, self.userNameLabel.lineBreakMode); CGFloat userNameHeight = 22; if (userNameWidth > 90) { userNameWidth = 90; userNameHeight = heightForString(self.creatUser.sname, self.userNameLabel.font, userNameWidth, self.userNameLabel.lineBreakMode); } self.userNameLabel.frame = CGRectMake(65-userNameWidth/2, CGRectGetMaxY(self.headImageView.frame)+12, userNameWidth, userNameHeight); self.headImageView.imageUrl = self.creatUser.pic; if ([self.creatUser.isAuth intValue] == 1) { self.vImg.hidden = NO; }else { self.vImg.hidden = YES; } self.userNameLabel.text = self.creatUser.sname; CGFloat userDescHeight = heightForString(self.creatUser.perDesc, appFont(15, NO), 190/2, NSLineBreakByWordWrapping); self.userDescLabel.text = self.creatUser.perDesc; self.userDescLabel.frame = CGRectMake(17, CGRectGetMaxY(self.userNameLabel.frame)+17, 190/2, userDescHeight); if (isCreatPage) { self.openAskButton.hidden = NO; self.askButton.hidden = YES; }else { self.openAskButton.hidden = YES; self.askButton.hidden = NO; } } - (AsyncImageView*)headImageView { if (!_headImageView) { _headImageView = [[AsyncImageView alloc]initWithFrame:CGRectMake(35, 20, 60, 60)]; _headImageView.layer.cornerRadius = 30; _headImageView.clipsToBounds = YES; _headImageView.isHaveWaterPrint = NO; } return _headImageView; } -(UIButton *)headBtn{ if(!_headBtn){ _headBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _headBtn.backgroundColor = [UIColor clearColor]; [_headBtn setBackgroundImage:imageWithUIColor([UIColor clearColor]) forState:UIControlStateNormal]; [_headBtn addTarget:self action:@selector(headBtnEvent:) forControlEvents:UIControlEventTouchUpInside]; } return _headBtn; } -(UIImageView *)vImg{ if (!_vImg) { _vImg = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.headImageView.frame)-16, CGRectGetMaxY(self.headImageView.frame)-20, 20, 20)]; _vImg.image = Image(@"topic/vipIcon.png"); } return _vImg; } - (UILabel*)userNameLabel { if (!_userNameLabel) { _userNameLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _userNameLabel.font = appFont(17, NO); _userNameLabel.textColor = [UIColor colorWithHexString:TextBlack]; _userNameLabel.textAlignment = NSTextAlignmentLeft; _userNameLabel.lineBreakMode = NSLineBreakByWordWrapping; _userNameLabel.numberOfLines = 0; _userNameLabel.backgroundColor = [UIColor clearColor]; } return _userNameLabel; } - (UILabel *)userDescLabel { if (!_userDescLabel) { _userDescLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _userDescLabel.font = appFont(15, NO); _userDescLabel.textColor = [UIColor colorWithHexString:TextGray]; _userDescLabel.textAlignment = NSTextAlignmentLeft; _userDescLabel.lineBreakMode = NSLineBreakByWordWrapping; _userDescLabel.numberOfLines = 0; _userDescLabel.backgroundColor = [UIColor clearColor]; } return _userDescLabel; } - (UIView*)topicView { if (!_topicView) { _topicView = [[UIView alloc]initWithFrame:CGRectMake(CGRectGetWidth(self.view.bounds)-70, 0, 70, CGRectGetHeight(self.navigationController.navigationBar.bounds))]; _topicView.backgroundColor = [UIColor clearColor]; UIButton *topicBtn = [UIButton buttonWithType:UIButtonTypeCustom]; topicBtn.backgroundColor = [UIColor clearColor]; [topicBtn setTitle:@"问吧" forState:UIControlStateNormal]; [topicBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [topicBtn setTitleColor:[UIColor colorWithHexString:TextLightGray] forState:UIControlStateHighlighted]; topicBtn.frame = _topicView.bounds; topicBtn.titleLabel.font = appFont(18, NO); [topicBtn addTarget:self action:@selector(goToTopicList:) forControlEvents:UIControlEventTouchUpInside]; [_topicView addSubview:topicBtn]; } return _topicView; } -(shareButton *)shareBtn{ if (!_shareBtn) { _shareBtn = [[shareButton alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.headImageView.frame)+ CGRectGetWidth(self.headImageView.bounds)/2 - 72/2, CGRectGetHeight(self.view.bounds)-77, 72, 72)]; [_shareBtn setImage:Image(@"detailPage/shareBtn.png") forState:UIControlStateNormal]; [_shareBtn setImage:Image(@"detailPage/shareBtn.png") forState:UIControlStateHighlighted]; [_shareBtn setImage:Image(@"detailPage/shareBtn.png") forState:UIControlStateDisabled]; [_shareBtn addTarget:self action:@selector(shareHandler:) forControlEvents:UIControlEventTouchUpInside]; } return _shareBtn; } - (toolBarBtnView*)askButton { if (!_askButton) { _askButton = [[toolBarBtnView alloc]initWithFrame:CGRectMake(30,685/2, 70, 60) withTarget:self selector:@selector(goToAsk:) buttonImage:@"topic/topicAsk.png" hilightImage:@"topic/topicAsk_h.png" selectImage:nil]; _askButton.edgeInsets =UIEdgeInsetsMake(0, 35-18, 60-36, 35-18); _askButton.titleText = @"提问"; } return _askButton; } - (TPSelectButton*)praiseButton { if (!_praiseButton) { _praiseButton = [[TPSelectButton alloc]initWithFrame:CGRectMake(30,CGRectGetMaxY(self.askButton.frame)+40, 70, 50) target:self selector:@selector(praiseHandler:)]; [_praiseButton setBUttonNormalImage:Image(@"detailPage/praiseImg.png") highLightImage:Image(@"detailPage/praiseImg_h.png") selectedImage:Image(@"detailPage/praiseImg_s.png")]; _praiseButton.textLabel.font = appFont(11, NO); } return _praiseButton; } - (TPSelectButton*)openAskButton { if (!_openAskButton) { _openAskButton = [[TPSelectButton alloc]initWithFrame:CGRectMake(30,685/2, 70, 55) target:self selector:@selector(openAsk:)]; [_openAskButton setBUttonNormalImage:Image(@"topic/topicOpenAsk.png") highLightImage:nil selectedImage:Image(@"topic/topicOpenAsk_s.png")]; _openAskButton.textLabel.font = appFont(11, NO); } return _openAskButton; } #pragma mark - handler - (void)backButtonHandler:(id)sender { [self.navigationController popViewControllerAnimated:YES]; } - (void)shareHandler:(shareButton*)btn { if (!self.topicInfo) { return; } if (self.shareVC) { [self.shareVC removeFromParentViewController]; [self.shareVC.view removeFromSuperview]; self.shareVC = nil; } self.shareVC = [[TPShareContentControlelr alloc]init]; self.shareVC.direction = expandRight; self.shareVC.sharestyle = shareTopicStyle; self.shareVC.startPoint = CGPointMake(CGRectGetMinX(self.headImageView.frame)+ CGRectGetWidth(self.headImageView.bounds)/2 - 72/2, CGRectGetHeight(self.view.bounds)-77); if (isNotIOS7) { self.shareVC.startPoint = CGPointMake(CGRectGetMinX(self.headImageView.frame)+ CGRectGetWidth(self.headImageView.bounds)/2 - 72/2, CGRectGetHeight(self.view.bounds)-87); } self.shareVC.view.bounds = self.view.bounds; contentObjectBO *contentBO = contentObjectBO.new; // contentBO.sharePic = self.liveInfoBO.sharePic; // contentBO.shareUrl = self.liveInfoBO.shareUrl; // contentBO.name = self.liveInfoBO.name; // contentBO.summary = shareText; contentBO.sharePic = @"other/topicLogo.jpg"; contentBO.shareUrl = self.topicInfo.shareUrl; contentBO.name = self.topicInfo.title; contentBO.summary = self.topicInfo.desc; self.shareVC.contentBO = contentBO; self.shareVC.delegate = self; // self.shareVC.contentBO = self.topicInfo; [self addChildViewController:self.shareVC]; [self.view addSubview:self.shareVC.view]; self.shareBtn.enabled = NO; // [self.view bringSubviewToFront:self.tableVC.view]; } -(void) headBtnEvent:(UIButton *)btn{ commentObjectVO *comment = commentObjectVO.new; comment.commentId = self.topicInfo.topicId; comment.userInfo = self.topicInfo.userInfo; otherPersonHomepageController *otherVC = [otherPersonHomepageController new]; otherVC.commentBo = comment; [self.navigationController pushViewController:otherVC animated:YES]; } - (void)goToTopicList:(UIButton*)btn { [self dismissContent]; customFlowLayout *layout = nil; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; CGSize itemSize = CGSizeZero; layout= [[customFlowLayout alloc]init]; layout.scrollDirection = UICollectionViewScrollDirectionVertical; layout.minimumLineSpacing = 35; layout.minimumInteritemSpacing = 35; CGFloat width = 0; if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) { width = (self.view.bounds.size.width-35*3)/2; }else { width = (self.view.bounds.size.width-35*4)/3; } CGFloat viewScale = width/600; itemSize = CGSizeMake(width, 450*viewScale); layout.itemSize = itemSize; topicListHomeController *topicController = [[topicListHomeController alloc]initWithCollectionViewLayout:layout]; [self.navigationController pushViewController:topicController animated:YES]; } - (void)goToAsk:(UIButton*)btn { if ([self.topicInfo.status intValue] == 3) { ShowTextMessage(@"此话题已关闭,不接受新提问"); return; } [self writeComment:interactionAskType commentBO:nil]; } -(void)topicTableToAsk{ [self goToAsk:nil]; } - (void)answerByCreatInTopic:(commentObjectVO *)commentBO { [self writeComment:interactionCommentType commentBO:commentBO]; } - (void)praiseHandler:(UIButton*)btn { if (!self.topicInfo) { return; } if (btn.selected) { return; } [self.praiseButton setSelected:YES animated:YES];//【需求】点赞动画(bug:4969) NSDictionary *dic = @{@"topicId":self.topicInfo.topicId,@"otype":@3}; __weak typeof(self) Self = self; [Remote doJsonActionWithBlock:2000 requestUrl:optTopicURL parameter:dic withWaitCursor:NO completion:^(BOOL success, NSString *message, id responseData) { if (success) { [MobClick event:@"33"]; NSString *praseNum = [NSString stringWithFormat:@"%@",responseData[@"praiseTimes"]]; if([praseNum intValue] <1000){//点赞:点赞超过1K的,几个页面会出现显示不全的现象(bug:5371) Self.praiseButton.textLabel.text = praseNum; } // Self.praiseButton.textLabel.text = praseNum; TPLOG(@"点赞成功"); //点赞按钮:点赞按钮点赞后,再次点击异常(bug:5370) Self.praiseButton.userInteractionEnabled = NO; // [Self.praiseButton setSelect:YES animation:YES]; }else { ShowMessage(@"点赞失败", NO); } }]; } - (void)openAsk:(UIButton*)btn { NSMutableDictionary *dic = [NSMutableDictionary dictionary]; if (btn.selected) {//otype == 2 关闭 [dic setObject:self.topicInfo.topicId forKey:@"topicId"]; [dic setObject:@2 forKey:@"otype"]; }else{//otype == 4 开启 [dic setObject:self.topicInfo.topicId forKey:@"topicId"]; [dic setObject:@4 forKey:@"otype"]; } [Remote doJsonActionWithBlock:2001 requestUrl:optTopicURL parameter:dic withWaitCursor:YES completion:^(BOOL success, NSString *message, id responseData) { if (success) { if(!btn.selected){ TPLOG(@"已开启提问"); ShowTextMessage(@"已开启提问"); self.topicInfo.status = @"3"; btn.selected = !btn.selected; [self.openAskButton setTitleText:@"关闭提问"]; self.tableVC.statusLabel.text = @"进行中..."; }else{ TPLOG(@"已关闭提问"); ShowTextMessage(@"已关闭提问"); self.topicInfo.status = @"1"; btn.selected = !btn.selected; [self.openAskButton setTitleText:@"开启提问"]; self.tableVC.statusLabel.text = @"已关闭提问"; } }else { if(btn.selected){ ShowMessage(@"关闭提问失败", NO); }else{ ShowMessage(@"开启提问失败", NO); } } }]; } - (void)writeComment:(commentAndAskType)type commentBO:(commentObjectVO*)commentBO{ __weak typeof(self) Self = self; if (![TPUserDefault instance].userBO) { loginPopUpController *loginVC = loginPopUpController.new; [self presentController:loginVC animated:YES presentSize:loginPopUpSize completion:^{ } dismiss:^{ if ([TPUserDefault instance].userBO) { Self.writeCommentContentVC = [[writeCommentAndAskController alloc]init]; Self.writeCommentContentVC.type = type; Self.writeCommentContentVC.nodeId = Self.topicInfo.topicId; Self.writeCommentContentVC.delegate = Self; Self.writeCommentContentVC.commentOT = @"3"; if (commentBO) { Self.writeCommentContentVC.commentBO = commentBO; } [Self presentController:Self.writeCommentContentVC animated:YES presentSize:writeAndAskPopSize completion:^{ } dismiss:^{ Self.writeCommentContentVC = nil; } tapHandler:^{ [Self.writeCommentContentVC closeKeyBoard]; }]; } }]; }else { Self.writeCommentContentVC = [[writeCommentAndAskController alloc]init]; Self.writeCommentContentVC.type = type; Self.writeCommentContentVC.nodeId = Self.topicInfo.topicId; Self.writeCommentContentVC.delegate = self; Self.writeCommentContentVC.commentOT = @"3"; if (commentBO) { Self.writeCommentContentVC.commentBO = commentBO; } [Self presentController:Self.writeCommentContentVC animated:YES presentSize:writeAndAskPopSize completion:^{ } dismiss:^{ Self.writeCommentContentVC = nil; } tapHandler:^{ [Self.writeCommentContentVC closeKeyBoard]; }]; } } - (void)commentSuccess:(commentAndAskType)type { if (type == interactionAskType) { // ShowTextMessageWithDelay(@"提问成功,如果题主回答了你的问题,就会在话题页中显示出来", 3); [self.tableVC refreshNumAfterAsk]; [self setAttentionAlert]; }else { ShowTextMessage(@"发表成功"); [self.tableVC reloadAskCellAfterAsking]; } } #pragma mark - remote delegate - (void)remoteResponsSuccess:(int)actionTag withResponsData:(id)responsData { if (actionTag == 0) { self.topicInfo = setJsonDicToDataModel(responsData[@"topicInfo"], [TopicInfoBO class]); self.topicInfo.desc = responsData[@"topicInfo"][@"description"]; NSString *newNums = responsData[@"topicInfo"][@"newNums"]; if (newNums) { self.topicInfo.unNums = newNums; } if(isCreatPage) { if ([self.topicInfo.status intValue] == 3) { self.openAskButton.button.selected = NO; self.openAskButton.titleText = @"开放提问"; }else if ([self.topicInfo.status intValue] == 1) { self.openAskButton.button.selected = YES; self.openAskButton.titleText = @"关闭提问"; } } userBO *user = setJsonDicToDataModel(self.topicInfo.userInfo, [userBO class]); if ([[TPUserDefault instance].userBO.userId intValue] == [user.userId intValue]) { self.tableVC.isCreat = YES; }else{ self.tableVC.isCreat = NO; } self.creatUser = user; [self setUserInfo]; self.praiseButton.titleText = self.topicInfo.praiseTimes; self.tableVC.topicInfo = self.topicInfo; self.tableVC.topicPageVO = setJsonDicToDataModel(responsData, [topicInfoPageVO class]); } } #pragma mark - orentation - (void)statusBarOrientationChange:(NSNotification *)notification { UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) { if (self.view.bounds.size.width > self.view.bounds.size.height) { self.view.frame =CGRectMake(0, 0, self.view.bounds.size.height, self.view.bounds.size.width); } }else { if (self.view.bounds.size.width < self.view.bounds.size.height) { self.view.frame =CGRectMake(0, 0, self.view.bounds.size.height, self.view.bounds.size.width); } } self.tableVC.view.frame = CGRectMake(130, topPadding, CGRectGetWidth(self.view.bounds)-130, CGRectGetHeight(self.view.bounds)-topPadding); self.topicView.frame = CGRectMake(CGRectGetWidth(self.view.bounds)-70, 0, 70, CGRectGetHeight(self.navigationController.navigationBar.bounds)); self.shareBtn.frame = CGRectMake(CGRectGetMinX(self.headImageView.frame)+ CGRectGetWidth(self.headImageView.bounds)/2 - 72/2, CGRectGetHeight(self.view.bounds)-77, 72, 72); if (isNotIOS7) { self.shareBtn.frame = CGRectMake(CGRectGetMinX(self.headImageView.frame)+ CGRectGetWidth(self.headImageView.bounds)/2 - 72/2, CGRectGetHeight(self.view.bounds)-97, 72, 72); } [self.shareVC.view removeFromSuperview]; self.shareBtn.enabled = YES; [self.shareVC dismissViewControllerAnimated:YES completion:^{ [self.shareVC removeFromParentViewController]; self.shareVC = nil; }]; //【倒退】【适配性】ios7,分享:系统分享,闪退(bug:5674) if (isNotIOS8) { if ([shareUtil instance].popController &&[shareUtil instance].popController.isPopoverVisible) { [[shareUtil instance].popController dismissPopoverAnimated:YES]; } } // if (self.shareVC) { // self.shareVC.startPoint = CGPointMake(CGRectGetMinX(self.headImageView.frame)+ CGRectGetWidth(self.headImageView.bounds)/2 - 72/2, CGRectGetHeight(self.view.bounds)-77); // if (isNotIOS7) { // self.shareVC.startPoint = CGPointMake(CGRectGetMinX(self.headImageView.frame)+ CGRectGetWidth(self.headImageView.bounds)/2 - 72/2, CGRectGetHeight(self.view.bounds)-97); // } // } } #pragma mark - sharecontent delegate - (void)dismissContent { [self.shareVC.view removeFromSuperview]; [self.shareVC removeFromParentViewController]; self.shareVC = nil; self.shareBtn.enabled = YES; } - (void)remoteResponsFailed:(int)actionTag withMessage:(NSString *)message resultCode:(NSString *)code { if ([code intValue] == 5) { [self topicHaveOfflined:YES]; [TPUserDefault instance].lastContentID = @""; [TPUserDefault instance].lastContentOffset = CGPointZero; }else { if (actionTag == 0 && [message isEqualToString:@"请求超时,请稍后重试!"]) { [self networkTimeOut]; }else { ShowTextMessage(message); } } } - (void)refreshPage { NSString *forWardType = @""; if (self.creatUser) { if ([[TPUserDefault instance].userBO.userId intValue] == [self.creatUser.userId intValue]) { forWardType = @"6"; isCreatPage = YES; }else { forWardType = @"5"; isCreatPage = NO; } [self setUserInfo]; }else { if (isCreatPage) { forWardType = @"6"; }else { forWardType = @"5"; } } NSDictionary *dic = @{@"topicId":self.preTopicInfo.topicId,@"forwordType":forWardType}; [Remote doJsonAction:0 requestUrl:topicInfoURL parameter:dic delegate:self]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void) setAttentionAlert{ if ([[TPUserDefault instance].isAttention intValue] == 0 && ![self.tableVC getAttentionStatus]) { UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"对这个话题感兴趣? 关注话题,掌握话题最新动态" delegate:self cancelButtonTitle:@"关注" otherButtonTitles:@"暂不关注",nil]; [alert show]; [TPUserDefault instance].isAttention = @"1"; } } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { NSDictionary *dic = @{@"ot":@"1",@"commentId":self.topicInfo.topicId}; [Remote doJsonActionWithBlock:1 requestUrl:addAttentionURL parameter:dic withWaitCursor:YES completion:^(BOOL success, NSString *message, id responseData) { if (success) { [MobClick event:@"34"]; ShowMessage(@"关注成功", YES); TopicInfoBO* topicData = self.topicInfo; topicData.isAttented = @"1"; [MobClick event:@"39"]; [self.tableVC changeAttention]; }else { ShowTextMessage(message); } }]; } } /* #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