//適配iOS 6 [(UIView *)[self viewWithTag:lineTag] removeFromSuperview]; UIColor *LCN = [[ThemeManager sharedThemeManager] colorWithColorKey:COLOR_LCN]; UIView *line = [[UIView alloc] initWithFrame:CGRectMake(50, 59.5, 270, 0.5)]; line.backgroundColor = LCN; [self addSubview:line];
//調用彈窗 [self creatAlertForCompleteMessage:@"評價完成,確認提交嗎?" tag:1]; - (void)creatAlertForCompleteMessage:message tag:(int)tag{ if (tag == 1) { if ([ResourceUtil getSystemVersion] >= 8.0) { MSGSAlertController *alert = [MSGSAlertController alertControllerWithTitle:nil message:message preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { }]; UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"確認" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [self startLoading]; dispatch_async([[GCDUtil sharedGCDUtil] defaultRequestQueue], ^{ if (!EMPTY_STRING(commentsTextView.text)) { content = commentsTextView.text; } content = [[EmojiUtil sharedEmojiUtil] emojiEnglishFormChinese:content]; [self.playService submitApprasialInfoWithPlayId:self.playInfo.playid OrderId:self.playInfo.playOrder.playOrderId star:stars desc:desc content:content images:selectedImages Success:^() { dispatch_async(dispatch_get_main_queue(), ^{ [self stopLoading]; if ([self.isAppraisalSucessDelegate respondsToSelector:@selector(isAppraisalSucess:)]) { [self.isAppraisalSucessDelegate isAppraisalSucess:YES]; } [self.navigationController popViewControllerAnimated:YES]; [self showToast:@"評價提交成功"]; }); } failure:^(NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{ [self showError:error]; [self stopLoading]; }); }]; }); }]; [alert addAction:cancelAction]; [alert addAction:okAction]; [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alert animated:YES completion:nil]; }else{ UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil message:message delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確認", nil]; [alert show]; [alert setTag:tag]; [[MSGSAdapterUtil sharedAdapterUtil] setAlertView:alert]; } } } //適配iOS 8如下系統 - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{ if (alertView.tag == 1) { if (buttonIndex == 1) { [self startLoading]; dispatch_async([[GCDUtil sharedGCDUtil] defaultRequestQueue], ^{ if (!EMPTY_STRING(commentsTextView.text)) { content = commentsTextView.text; } content = [[EmojiUtil sharedEmojiUtil] emojiEnglishFormChinese:content]; [self.playService submitApprasialInfoWithPlayId:self.playInfo.playid OrderId:self.playInfo.playOrder.playOrderId star:stars desc:desc content:content images:selectedImages Success:^() { dispatch_async(dispatch_get_main_queue(), ^{ [self stopLoading]; if ([self.isAppraisalSucessDelegate respondsToSelector:@selector(isAppraisalSucess:)]) { [self.isAppraisalSucessDelegate isAppraisalSucess:YES]; } [self.navigationController popViewControllerAnimated:YES]; [self showToast:@"評價提交成功"]; }); } failure:^(NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{ [self showError:error]; [self stopLoading]; }); }]; }); } } }
#pragma mark - textView Delegate for pad - (void)textViewDidChange:(UITextView *)textView{ if(textView.text.length == 0) { _commentInfoRightLabel.alpha = 1; _commentInfoRightLabel.hidden = NO; } else { _commentInfoRightLabel.alpha = 0; _commentInfoRightLabel.hidden = YES; } if(_commentInfoRightTextView == textView){ float contentSizeHeight = textView.contentSize.height; if (contentSizeHeight < 54) { contentSizeHeight = 54; } frameSizeHeight = textView.frame.size.height; float height = contentSizeHeight - frameSizeHeight; textView.frame = CGRectMake(textView.frame.origin.x, textView.frame.origin.y, textView.frame.size.width, contentSizeHeight); _commentInfoView.frame = CGRectMake(_commentInfoView.frame.origin.x, _commentInfoView.frame.origin.y, _commentInfoView.frame.size.width, textView.frame.size.height); [self updateContentViewFrame:height]; } if ([textView.text isEqualToString:@"\n"]){ return ; } NSString * toBeString = textView.text; if (_commentInfoRightTextView == textView) { if ([MSGSUtility convertToDouble:toBeString]>100) { textView.text = [MSGSUtility subStringFromStr:toBeString withCharacterLenght:100]; [self showToast:@"輸入字數不能超過50字哦!"]; return ; } } return ; }
#pragma mark - textView Delegate for iphone -(BOOL) textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{ if ([text isEqualToString:@"\n"]){ return NO; } NSString * toBeString = [textView.text stringByReplacingCharactersInRange:range withString:text]; if (_commentInfoRightTextView == textView) { if ([MSGSUtility convertToDouble:toBeString]>100) { textView.text = [MSGSUtility subStringFromStr:toBeString withCharacterLenght:100]; [self showToast:@"輸入字數不能超過50字哦!"]; return NO; } } return YES; }
NSString *name = user.nickName; CGSize size = CGSizeMake(110,22); CGFloat originX; nickName.numberOfLines = 1; if([ResourceUtil getSystemVersion] >= 7.0){ CGRect rect = [name boundingRectWithSize:size options:NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName: nickName.font} context:nil]; originX = 160 - (rect.size.width + 9 + 16)/2; //暱稱和等級居中顯示 nickName.frame = CGRectMake(originX, nickName.frame.origin.y, rect.size.width, rect.size.height); }else{ CGSize labelsize = [name sizeWithFont:nickName.font constrainedToSize:size lineBreakMode:NSLineBreakByWordWrapping]; originX = 160 - (labelsize.width + 9 + 16)/2; //暱稱和等級居中顯示 nickName.frame = CGRectMake(originX, nickName.frame.origin.y, labelsize.width, labelsize.height); } vipButton.frame = CGRectMake(nickName.frame.origin.x + nickName.frame.size.width + 9, nickName.frame.origin.y + 2, 22, 15); [nickName setText:GET_STRING(name)];