Commit 898d2d88 authored by admin's avatar admin

修复部分bug

parent de243197
......@@ -135,6 +135,9 @@
#define kTaxisViewHeight 150
#define kScreenViewHeight 240
#define kRefreshInspectPointNotification @"refreshInspectPoint"
#define kRefreshQuestionNotification @"refershQuestionList"
#import "UIView+Extension.h"
......
......@@ -11,6 +11,7 @@
@interface CommentView : UIView <UITextViewDelegate>
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIButton *quitBtn;
@property (nonatomic, strong) UILabel *placeholderLabel2;
@property (nonatomic, strong) UILabel *commentLabel;
......
......@@ -11,7 +11,6 @@
#define kStarBarWidth 235
@interface CommentView ()
@property (nonatomic, strong) UILabel *placeholderLabel2;
@property (nonatomic, strong) UIImageView *backImageView2;
@end
......
......@@ -149,6 +149,7 @@
NSLog(@"上传新问题 response= %@, error = %@", response, error);
if (response[@"success"]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"新问题提报成功!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
alert.tag = 90393;
[alert show];
[MBProgressHUD hideHUDForView:self.view animated:YES];
} else {
......@@ -157,7 +158,6 @@
}
}];
}
// 返回上一页面
......@@ -175,6 +175,17 @@
#pragma mark - UIAlertViewDelegate
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0 && alertView.tag == 90393) {
[self.navigationController popViewControllerAnimated:YES];
NSNotificationCenter *notification = [NSNotificationCenter defaultCenter];
[notification postNotificationName:kRefreshQuestionNotification object:self];
}
}
#pragma mark - TakePhoto Delegate
- (void)deletePhoto:(UIButton *)button
{
......@@ -448,9 +459,18 @@
if ([text isEqualToString:@"\n"]) {
[self.footerView.titleTextView resignFirstResponder];
[self.footerView.contentTextView resignFirstResponder];
if (textView.text.length != 0) {
self.footerView.placeholderLabel1.hidden = YES;
self.footerView.placeholderLabel2.hidden = YES;
} else {
self.footerView.placeholderLabel1.hidden = NO;
self.footerView.placeholderLabel2.hidden = NO;
}
return NO;
}
return YES;
}
......
......@@ -11,6 +11,7 @@
#import "QuestionDetailModel.h"
@interface QuestionDetailCell : UITableViewCell
@property (nonatomic, strong) UILabel *questionName; // 问题名称
@property (nonatomic, strong) UILabel *stateLabel; // 状态
@property (nonatomic, strong) ZanButton *thumbBtn; // 状态
@property (nonatomic, strong) UILabel *sortLabel; // 分类
......
......@@ -32,18 +32,24 @@
{
_questionDetail = questionDetail;
NSString *questionNameText = [NSString stringWithFormat:@"问题名称:%@", questionDetail.title];
NSMutableAttributedString *questionNameAttr = [[NSMutableAttributedString alloc] initWithString:questionNameText];
[questionNameAttr addAttributes:@{NSForegroundColorAttributeName:kDetailCellDescribeTextColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(0,5)];
[questionNameAttr addAttributes:@{NSForegroundColorAttributeName:kdetailCellTitleColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(5,questionNameText.length - 5)];
[self.questionName setAttributedText:questionNameAttr];
// 状态
if ([questionDetail.state isEqualToString:@"resolved"]) {
NSString *stateText = [NSString stringWithFormat:@"状态:已解决"];
NSMutableAttributedString *stateAttr = [[NSMutableAttributedString alloc] initWithString:stateText];
[stateAttr addAttributes:@{NSForegroundColorAttributeName:kDetailCellDescribeTextColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(0,3)];
[stateAttr addAttributes:@{NSForegroundColorAttributeName:kNavigationBarColor,NSFontAttributeName:[UIFont boldSystemFontOfSize:15.0f]} range:NSMakeRange(3,stateText.length - 3)];
[stateAttr addAttributes:@{NSForegroundColorAttributeName:kNavigationBarColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(3,stateText.length - 3)];
[self.stateLabel setAttributedText:stateAttr];
} else {
NSString *stateText = [NSString stringWithFormat:@"状态:已创建"];
NSMutableAttributedString *stateAttr = [[NSMutableAttributedString alloc] initWithString:stateText];
[stateAttr addAttributes:@{NSForegroundColorAttributeName:kDetailCellDescribeTextColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(0,3)];
[stateAttr addAttributes:@{NSForegroundColorAttributeName:kdetailCellTitleColor,NSFontAttributeName:[UIFont boldSystemFontOfSize:15.0f]} range:NSMakeRange(3,stateText.length - 3)];
[stateAttr addAttributes:@{NSForegroundColorAttributeName:kdetailCellTitleColor,NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} range:NSMakeRange(3,stateText.length - 3)];
[self.stateLabel setAttributedText:stateAttr];
}
......@@ -91,6 +97,34 @@
}
#pragma mark - lazy loading
- (UILabel *)questionName
{
if (!_questionName) {
_questionName = [[UILabel alloc] init];
_questionName.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_questionName];
// 顶端
NSLayoutConstraint *stateTop = [NSLayoutConstraint constraintWithItem:_questionName attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:10];
[self.contentView addConstraint:stateTop];
// 左边
NSLayoutConstraint *stateLeft = [NSLayoutConstraint constraintWithItem:_questionName attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:stateLeft];
// 右边
NSLayoutConstraint *stateRight = [NSLayoutConstraint constraintWithItem:_questionName attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.thumbBtn attribute:NSLayoutAttributeLeft multiplier:1.0 constant:-5];
[self.contentView addConstraint:stateRight];
// 高度
NSLayoutConstraint *stateHeight = [NSLayoutConstraint constraintWithItem:_questionName attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[self.contentView addConstraint:stateHeight];
}
return _questionName;
}
- (UILabel *)stateLabel
{
if (!_stateLabel) {
......@@ -99,7 +133,7 @@
[self.contentView addSubview:_stateLabel];
// 顶端
NSLayoutConstraint *stateTop = [NSLayoutConstraint constraintWithItem:_stateLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:10];
NSLayoutConstraint *stateTop = [NSLayoutConstraint constraintWithItem:_stateLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.questionName attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:stateTop];
// 左边
......@@ -124,20 +158,20 @@
[_thumbBtn setImage:[UIImage imageNamed:@"commend"] forState:UIControlStateNormal];
[_thumbBtn setImage:[UIImage imageNamed:@"commend_after"] forState:UIControlStateSelected];
_thumbBtn.translatesAutoresizingMaskIntoConstraints = NO;
_thumbBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
_thumbBtn.titleLabel.font = [UIFont systemFontOfSize:16.0];
[_thumbBtn setTitleColor:kNavigationBarColor forState:UIControlStateNormal];
[self.contentView addSubview:_thumbBtn];
// 顶端
NSLayoutConstraint *thumbTop = [NSLayoutConstraint constraintWithItem:_thumbBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:13];
NSLayoutConstraint *thumbTop = [NSLayoutConstraint constraintWithItem:_thumbBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:12];
[self.contentView addConstraint:thumbTop];
// 左边
NSLayoutConstraint *thumbWidth = [NSLayoutConstraint constraintWithItem:_thumbBtn attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:80];
// // 左边
NSLayoutConstraint *thumbWidth = [NSLayoutConstraint constraintWithItem:_thumbBtn attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:75];
[self.contentView addConstraint:thumbWidth];
// 右边
NSLayoutConstraint *thumbRight = [NSLayoutConstraint constraintWithItem:_thumbBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
NSLayoutConstraint *thumbRight = [NSLayoutConstraint constraintWithItem:_thumbBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-10];
[self.contentView addConstraint:thumbRight];
// 高度
......
......@@ -161,24 +161,6 @@
}
- (void)textViewDidBeginEditing:(UITextView *)textView
{
[UIView animateWithDuration:0.3 animations:^{
_commentView.frame = CGRectMake(0, self.view.frame.size.height - kCommentViewHeight - 173, kScreenWidth, kCommentViewHeight);
}];
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
[UIView animateWithDuration:0.3 animations:^{
_commentView.frame = CGRectMake(0, self.view.frame.size.height - kCommentViewHeight, kScreenWidth, kCommentViewHeight);
}];
}
//-(void)textFieldDidBeginEditing:(UITextField *)textField
//{
//
//}
......@@ -296,6 +278,44 @@
#pragma mark - UItextDelegate
- (void)textViewDidBeginEditing:(UITextView *)textView
{
[UIView animateWithDuration:0.3 animations:^{
_commentView.frame = CGRectMake(0, self.view.frame.size.height - kCommentViewHeight - 173, kScreenWidth, kCommentViewHeight);
}];
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
[UIView animateWithDuration:0.3 animations:^{
_commentView.frame = CGRectMake(0, self.view.frame.size.height - kCommentViewHeight, kScreenWidth, kCommentViewHeight);
}];
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
if (![text isEqualToString:@""]) {
_commentView.placeholderLabel2.hidden = YES;
}
if ([text isEqualToString:@""] && range.location == 0 && range.length == 1) {
_commentView.placeholderLabel2.hidden = NO;
}
if ([text isEqualToString:@"\n"]) {
[_commentView.contentTextView resignFirstResponder];
if (textView.text.length != 0) {
_commentView.placeholderLabel2.hidden = YES;
} else {
_commentView.placeholderLabel2.hidden = NO;
}
return NO;
}
return YES;
}
#pragma mark - UITableView Delegate/DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
......
......@@ -64,9 +64,19 @@
[self requestQuestionList];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(requestQuestionList)
name:kRefreshQuestionNotification
object:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
......@@ -91,6 +101,7 @@
}
#pragma mark - Private Methods
- (void)requestQuestionList
{
// 初始化数组
......@@ -117,16 +128,19 @@
NSDictionary *dataDict = (NSDictionary *)response[@"data"];
NSDictionary *recordsDict = (NSDictionary *)dataDict[@"records"];
NSLog(@"问题与知识列表recods = %@", response);
NSMutableArray *tempArray = [NSMutableArray array];
for (NSDictionary *questionDict in recordsDict) {
QuestionModel *question = [[QuestionModel alloc] init];
[question setValuesForKeysWithDictionary:questionDict];
[weakSelf.allQuestionArray addObject:question];
[tempArray addObject:question];
}
_allQuestionArray = tempArray;
if (_allQuestionArray.count == 0) {
weakSelf.noDataView.backgroundColor = [UIColor whiteColor];
[MBProgressHUD hideHUDForView:self.view animated:YES];
} else {
[weakSelf setupTableView];
[self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
......
......@@ -35,6 +35,8 @@
@implementation InspectNotUploadViewController
- (void)viewDidLoad
{
[super viewDidLoad];
......@@ -284,7 +286,7 @@
if (buttonIndex == 0 && alertView.tag == 39429234) {
[self.navigationController popViewControllerAnimated:YES];
NSNotificationCenter *notification = [NSNotificationCenter defaultCenter];
[notification postNotificationName:@"kReloadTableView" object:self];
[notification postNotificationName:kRefreshInspectPointNotification object:self];
}
}
......
......@@ -83,11 +83,16 @@
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(requestCurrentList)
name:@"kReloadTableView"
name:kRefreshInspectPointNotification
object:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
......
......@@ -77,10 +77,15 @@
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(requestCurrentList)
name:@"kReloadTableView"
name:kRefreshInspectPointNotification
object:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
......
......@@ -155,7 +155,6 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
self.tableView.tableHeaderView = self.headView;
// 设置下拉刷新
self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
// 进入刷新状态后会自动调用这个block
......@@ -163,10 +162,57 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
}];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(refreshInspectList)
name:kRefreshInspectPointNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(refreshQuestionList)
name:kRefreshQuestionNotification
object:nil];
}
-(void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)refreshAllData
{
[self refreshInspectList];
[self refreshRankingList];
[self refreshQuestionList];
}
- (void)refreshInspectList {
// 口碑任务
NSString *url3 = [NSString stringWithFormat:@"%@%@", kRedStarURL, kInspectListURL];
HttpClient *httpCilent3 = [[HttpClient alloc] initWithUrl:url3];
NSDictionary *parameters3 = @{@"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],
@"queryOrders":@[@{@"field":@"lastModifyInfo"}],
@"pageNumber":@(0),
@"pageSize":@(2)
};
[httpCilent3 getInspectListWithParameters:parameters3 completion:^(id response, NSError *error) {
NSLog(@"刷新!! = 巡检列表%@", response);
NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"];
NSMutableArray *inspectTempArr = [NSMutableArray array];
for (NSDictionary *dict in dataArray) {
TaskListModel *taskList = [[TaskListModel alloc] init];
[taskList setValuesForKeysWithDictionary:dict];
[inspectTempArr addObject:taskList];
}
_taskListDataArray = inspectTempArr;
[self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
[self.tableView.header endRefreshing];
}];
}
- (void)refreshRankingList {
// 口碑巡检
NSString *url1 = [NSString stringWithFormat:@"%@%@", kRedStarURL, kRankingListURL];
HttpClient *httpCilent1 = [[HttpClient alloc] initWithUrl:url1];
......@@ -190,8 +236,9 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
[self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}
- (void)refreshQuestionList {
// 问题与知识
NSString *url2 = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
......@@ -215,38 +262,12 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
[question setValuesForKeysWithDictionary:questionDict];
[questionTempArr addObject:question];
}
weakSelf.allQuestionArray = questionTempArr;
[self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
// 口碑任务
NSString *url3 = [NSString stringWithFormat:@"%@%@", kRedStarURL, kInspectListURL];
HttpClient *httpCilent3 = [[HttpClient alloc] initWithUrl:url3];
NSDictionary *parameters3 = @{@"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],
@"queryOrders":@[@{@"field":@"lastModifyInfo"}],
@"pageNumber":@(0),
@"pageSize":@(2)
};
[httpCilent3 getInspectListWithParameters:parameters3 completion:^(id response, NSError *error) {
NSLog(@"刷新!! = 巡检列表%@", response);
NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"];
NSMutableArray *inspectTempArr = [NSMutableArray array];
for (NSDictionary *dict in dataArray) {
TaskListModel *taskList = [[TaskListModel alloc] init];
[taskList setValuesForKeysWithDictionary:dict];
[inspectTempArr addObject:taskList];
}
_taskListDataArray = inspectTempArr;
_allQuestionArray = questionTempArr;
[self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
[self.tableView.header endRefreshing];
}];
}
}
- (void)viewWillAppear:(BOOL)animated
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment