Commit d0c3ab3c authored by admin's avatar admin

添加问题与知识的相关页面 口碑巡检详情相关界面

parent 71e9630b
This diff is collapsed.
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "add-photos_btn@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "add-photos_btn@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "figure_bg@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "figure_bg@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "grey-trilateral_down@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "grey-trilateral_down@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
...@@ -20,15 +20,19 @@ ...@@ -20,15 +20,19 @@
{ {
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
_window.backgroundColor = [UIColor whiteColor]; _window.backgroundColor = [UIColor whiteColor];
[_window makeKeyAndVisible];
// 设置根控制器 // 设置根控制器
LoginViewController *loginVC = [[LoginViewController alloc] init]; LoginViewController *loginVC = [[LoginViewController alloc] init];
self.window.rootViewController = loginVC; self.window.rootViewController = loginVC;
[_window makeKeyAndVisible];
return YES; return YES;
} }
- (void)applicationWillResignActive:(UIApplication *)application { - (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
......
//
// RootTabBarController.h
// redstar
//
// Created by admin on 15/11/3.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface RootTabBarController : UITabBarController
@end
//
// RootTabBarController.m
// redstar
//
// Created by admin on 15/11/3.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "RootTabBarController.h"
#import "HomeViewController.h"
#import "AnnounceViewController.h"
#import "ChartViewController.h"
#import "MineViewController.h"
@interface RootTabBarController ()
@end
@implementation RootTabBarController
- (void)viewDidLoad
{
[self setupTabbar];
}
//
- (void)setupTabbar
{
// 跳转到tabbarController
HomeViewController *home = [[HomeViewController alloc]init];
UINavigationController *homeNav = [self setUpOneChildViewController:home title:@"首页" imageName:@"home_unchecked" selImageName:@"home_checked"];
AnnounceViewController *announce = [[AnnounceViewController alloc] init];
UINavigationController *announceNav = [self setUpOneChildViewController:announce title:@"公告" imageName:@"notice_unchecked" selImageName:@"notice_checked"];
ChartViewController *chart = [[ChartViewController alloc] init];
UINavigationController *chartNav = [self setUpOneChildViewController:chart title:@"报表查询" imageName:@"report_unchecked" selImageName:@"report_checked"];
MineViewController *mine = [[MineViewController alloc] init];
mine.tabBarItem.title= @"我的";
mine.tabBarItem.image = [UIImage imageNamed:@"aboutme_unchecked"];
mine.tabBarItem.selectedImage = [[UIImage imageNamed:@"aboutme_checke"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
kNavigationBarColor, NSForegroundColorAttributeName,
nil] forState:UIControlStateSelected];
self.viewControllers = @[homeNav, announceNav, chartNav, mine];
}
// 添加一个控制器的属性
- (UINavigationController *)setUpOneChildViewController:(UIViewController *)vc title:(NSString *)title imageName:(NSString *)imageName selImageName:(NSString *)selImageName
{
// 添加TabBar按钮的图片文字
vc.title = title;
vc.tabBarItem.image = [UIImage imageNamed:imageName];
UIImage *selImage = [UIImage imageNamed:selImageName];
selImage = [selImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
vc.tabBarItem.selectedImage = selImage;
// 添加nav
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
[nav.navigationBar setBarTintColor:kNavigationBarColor];
[nav.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
return nav;
}
@end
...@@ -103,9 +103,19 @@ ...@@ -103,9 +103,19 @@
// #999999 // #999999
#define kQuestionStateColor [UIColor colorWithRed:153 / 255.0 green:153 / 255.0 blue:153 / 255.0 alpha:1.0] #define kQuestionStateColor [UIColor colorWithRed:153 / 255.0 green:153 / 255.0 blue:153 / 255.0 alpha:1.0]
// QuestionDetail
// #888888
#define kDetailCellDescribeTextColor [UIColor colorWithRed:136 / 255.0 green:136 / 255.0 blue:136 / 255.0 alpha:1.0]
// #444444
#define kdetailCellTitleColor [UIColor colorWithRed:68 / 255.0 green:68 / 255.0 blue:68 / 255.0 alpha:1.0]
// #999999
#define kLightGray [UIColor colorWithRed:153 / 255.0 green:153 / 255.0 blue:153 / 255.0 alpha:1.0]
// #444444
#define kLightBlack [UIColor colorWithRed:68 / 255.0 green:68 / 255.0 blue:68 / 255.0 alpha:1.0]
#import "UIView+Extension.h" #import "UIView+Extension.h"
......
//
// QuestionCommentCell.h
// redstar
//
// Created by admin on 15/11/3.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface QuestionCommentCell : UITableViewCell
@end
//
// QuestionCommentCell.m
// redstar
//
// Created by admin on 15/11/3.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "QuestionCommentCell.h"
@implementation QuestionCommentCell
#pragma mark - System Methods
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self setup];
}
return self;
}
#pragma mark - Private Methods
- (void)setup
{
}
@end
//
// QuestionDescribeCell.h
// redstar
//
// Created by admin on 15/11/3.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface QuestionDescribeCell : UITableViewCell
@property (nonatomic, strong) UILabel *titleLabel; // 标题
@property (nonatomic, strong) UILabel *describeLabel; // 描述
@property (nonatomic, strong) UILabel *pictureLabel; // 照片
@property (nonatomic, strong) UIImageView *pcitureImageView; // 照片
@property (nonatomic, strong) UILabel *feedbackLabel; // 反馈
@property (nonatomic, strong) UIView *feedbackBackView; // 反馈背景
@property (nonatomic, strong) UILabel *answerLabel; // 答案
@property (nonatomic, strong) UILabel *peopleLabel; // 解决人
@property (nonatomic, strong) UILabel *dateLabel; // 时间
@end
//
// QuestionDescribeCell.m
// redstar
//
// Created by admin on 15/11/3.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "QuestionDescribeCell.h"
@implementation QuestionDescribeCell
#pragma mark - System Methods
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self setup];
}
return self;
}
#pragma mark - Private Methods
- (void)setup
{
self.titleLabel.textColor = kDetailCellDescribeTextColor;
_titleLabel.text = @"问题与建议描述";
self.describeLabel.textColor = kdetailCellTitleColor;
_describeLabel.text = @"系统跟单维护在订单当天发出回访短信,此时商品可能尚未送达到用户,引起消费者的疑问和不解,进而引起客户的不满和投诉,建议集团把短信回访延后1-2天,也避免由此引起的客户抱怨。";
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:_describeLabel.text];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.alignment = NSTextAlignmentLeft;
paragraphStyle.lineSpacing = 6; //行自定义行高度
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [_describeLabel.text length])];
_describeLabel.attributedText = attributedString;
[self.describeLabel sizeToFit];
self.pictureLabel.textColor = kDetailCellDescribeTextColor;
_pictureLabel.text = @"照片";
}
#pragma mark - lazy loading
- (UILabel *)titleLabel
{
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:15.0];
_titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_titleLabel];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:10];
[self.contentView addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:titleLeft];
// 右边
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:titleRight];
// 高度
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[self.contentView addConstraint:titleHeight];
}
return _titleLabel;
}
- (UILabel *)describeLabel
{
if (!_describeLabel) {
_describeLabel = [[UILabel alloc] init];
_describeLabel.font = [UIFont systemFontOfSize:15.0];
_describeLabel.translatesAutoresizingMaskIntoConstraints = NO;
_describeLabel.numberOfLines = 0;
[self.contentView addSubview:_describeLabel];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_describeLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.titleLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5];
[self.contentView addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_describeLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:titleLeft];
// 右边
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_describeLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:titleRight];
}
return _describeLabel;
}
- (UILabel *)pictureLabel
{
if (!_pictureLabel) {
_pictureLabel = [[UILabel alloc] init];
_pictureLabel.font = [UIFont systemFontOfSize:15.0];
_pictureLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_pictureLabel];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_pictureLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.describeLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5];
[self.contentView addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_pictureLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:titleLeft];
// 右边
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_pictureLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:titleRight];
// 高度
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_pictureLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[self.contentView addConstraint:titleHeight];
}
return _pictureLabel;
}
@end
//
// QuestionDetailCell.h
// redstar
//
// Created by admin on 15/11/2.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "ZanButton.h"
@interface QuestionDetailCell : UITableViewCell
@property (nonatomic, strong) UILabel *stateLabel; // 状态
@property (nonatomic, strong) ZanButton *thumbBtn; // 状态
@property (nonatomic, strong) UILabel *sortLabel; // 分类
@property (nonatomic, strong) UILabel *shopLabel; // 商场
@property (nonatomic, strong) UILabel *peopleLabel; // 提报人
@property (nonatomic, strong) UILabel *dateLabel; // 提报时间
@end
//
// QuestionDetailViewController.h
// redstar
//
// Created by admin on 15/11/2.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface QuestionDetailViewController : UIViewController
@end
//
// QuestionDetailViewController.m
// redstar
//
// Created by admin on 15/11/2.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "QuestionDetailViewController.h"
#import "QuestionDetailCell.h"
#import "QuestionCommentCell.h"
#import "QuestionDescribeCell.h"
#define kQuestionDetailCell @"QuestionDetailCell" // 问题详情
#define kQuestionCommentCell @"QuestionCommentCell" // 评论
#define kQuestionDescribeCell @"QuestionDescribeCell" // 问题描述
@interface QuestionDetailViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *test1Array;
@property (nonatomic, strong) NSArray *test2Array;
@property (nonatomic, strong) NSArray *test3Array;
@end
@implementation QuestionDetailViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView registerClass:[QuestionDetailCell class] forCellReuseIdentifier:kQuestionDetailCell];
[self.tableView registerClass:[QuestionCommentCell class] forCellReuseIdentifier:kQuestionCommentCell];
[self.tableView registerClass:[QuestionDescribeCell class] forCellReuseIdentifier:kQuestionDescribeCell];
[self setupNav];
self.test1Array = [NSArray arrayWithObjects:@"该建议很好", @"有效提高了用户体验,建议多提类似建议", nil];
self.test2Array = [NSArray arrayWithObjects:@"李XX 集团XX总", @"王XX 某大区经理", nil];
self.test3Array = [NSArray arrayWithObjects:@"2015-09-10 10:21:43", @"2015-10-27 11:21:43", nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Private Methods
- (void)setupNav
{
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
[customLab setTextColor:[UIColor whiteColor]];
[customLab setText:@"问题详情"];
customLab.font = [UIFont boldSystemFontOfSize:19];
self.navigationItem.titleView = customLab;
}
#pragma mark - UITableView Delegate/DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0) {
return 1;
} else if (section == 1) {
return 1;
} else {
return _test1Array.count;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
QuestionDetailCell *cell=[tableView dequeueReusableCellWithIdentifier:kQuestionDetailCell];
if (!cell) {
cell = [[QuestionDetailCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kQuestionDetailCell];
}
return cell;
} else if (indexPath.section == 1) {
QuestionDescribeCell *cell=[tableView dequeueReusableCellWithIdentifier:kQuestionDescribeCell];
if (!cell) {
cell = [[QuestionDescribeCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kQuestionDescribeCell];
}
return cell;
} else {
QuestionCommentCell *cell=[tableView dequeueReusableCellWithIdentifier:kQuestionCommentCell];
if (!cell) {
cell = [[QuestionCommentCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kQuestionCommentCell];
}
return cell;
}
}
// cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
return 148;
} else if (indexPath.section == 1) {
return 200;
} else {
return 50;
}
}
// section高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0) {
return CGFLOAT_MIN;
} else if (section == 1) {
return CGFLOAT_MIN;
} else {
return 40;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return CGFLOAT_MIN;
}
//// 自定义section
//- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
//{
// // 创建sectionView
// UIView *sectionView = [[UIView alloc] init];
// sectionView.userInteractionEnabled = YES;
// sectionView.backgroundColor = kInspectSectionBackGroundColor;
//
// return sectionView;
//}
#pragma mark - lazy loading
- (UITableView *)tableView
{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView.translatesAutoresizingMaskIntoConstraints = NO;
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.showsHorizontalScrollIndicator = NO;
[self.view addSubview:_tableView];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.view addConstraint:tableTop];
NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.view addConstraint:tableLeft];
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.view addConstraint:tableRight];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:tableBottom];
}
return _tableView;
}
@end
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import "QuestionViewController.h" #import "QuestionViewController.h"
#import "QuestionListTableCell.h" #import "QuestionListTableCell.h"
#import "MenuButton.h" #import "MenuButton.h"
#import "QuestionDetailViewController.h"
#define kQuestionListCell @"questionListTableViewCell" #define kQuestionListCell @"questionListTableViewCell"
...@@ -32,7 +33,6 @@ ...@@ -32,7 +33,6 @@
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
} }
#pragma mark - Private Methods
#pragma mark - Private Methods #pragma mark - Private Methods
- (void)setupNav - (void)setupNav
...@@ -78,6 +78,13 @@ ...@@ -78,6 +78,13 @@
} }
// cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
QuestionDetailViewController *questionDetailVC = [[QuestionDetailViewController alloc] init];
[self.navigationController pushViewController:questionDetailVC animated:YES];
}
// cell的高度 // cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{ {
......
//
// InspectSettleCell.h
// redstar
//
// Created by admin on 15/11/4.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface InspectSettleCell : UITableViewCell
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *titleDetailLabel;
@property (nonatomic, strong) UILabel *introLabel;
@property (nonatomic, strong) UILabel *introDetailLabel;
@end
//
// InspectSettleCell.m
// redstar
//
// Created by admin on 15/11/4.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "InspectSettleCell.h"
@implementation InspectSettleCell
#pragma mark - System Methods
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self setup];
}
return self;
}
#pragma mark - Private Methods
- (void)setup {
}
#pragma - lazy loading
- (UILabel *)titleLabel
{
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
_titleLabel.font = [UIFont systemFontOfSize:15.0];
_titleLabel.textColor = kLightGray;
[self.contentView addSubview:_titleLabel];
NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:10];
[self.contentView addConstraint:overDateTop];
NSLayoutConstraint *overDateLeft = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:overDateLeft];
NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:overDateRight];
NSLayoutConstraint *overDateWidth = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[self.contentView addConstraint:overDateWidth];
}
return _titleLabel;
}
- (UILabel *)titleDetailLabel
{
if (!_titleDetailLabel) {
_titleDetailLabel = [[UILabel alloc] init];
_titleDetailLabel.translatesAutoresizingMaskIntoConstraints = NO;
_titleDetailLabel.font = [UIFont systemFontOfSize:15.0];
_titleDetailLabel.textColor = kLightBlack;
[self.contentView addSubview:_titleDetailLabel];
NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_titleDetailLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.titleLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:overDateTop];
NSLayoutConstraint *overDateLeft = [NSLayoutConstraint constraintWithItem:_titleDetailLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:overDateLeft];
NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_titleDetailLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:overDateRight];
NSLayoutConstraint *overDateWidth = [NSLayoutConstraint constraintWithItem:_titleDetailLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[self.contentView addConstraint:overDateWidth];
}
return _titleDetailLabel;
}
- (UILabel *)introLabel
{
if (!_introLabel) {
_introLabel = [[UILabel alloc] init];
_introLabel.translatesAutoresizingMaskIntoConstraints = NO;
_introLabel.font = [UIFont systemFontOfSize:15.0];
_introLabel.textColor = kLightGray;
[self.contentView addSubview:_introLabel];
NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_introLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.titleDetailLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:10];
[self.contentView addConstraint:overDateTop];
NSLayoutConstraint *overDateLeft = [NSLayoutConstraint constraintWithItem:_introLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:overDateLeft];
NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_introLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:overDateRight];
NSLayoutConstraint *overDateWidth = [NSLayoutConstraint constraintWithItem:_introLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[self.contentView addConstraint:overDateWidth];
}
return _introLabel;
}
- (UILabel *)introDetailLabel
{
if (!_introDetailLabel) {
_introDetailLabel = [[UILabel alloc] init];
_introDetailLabel.translatesAutoresizingMaskIntoConstraints = NO;
_introDetailLabel.font = [UIFont systemFontOfSize:15.0];
_introDetailLabel.numberOfLines = 0;
_introDetailLabel.textColor = kLightBlack;
[self.contentView addSubview:_introDetailLabel];
NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_introDetailLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.introLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:overDateTop];
NSLayoutConstraint *overDateLeft = [NSLayoutConstraint constraintWithItem:_introDetailLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:overDateLeft];
NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_introDetailLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:overDateRight];
NSLayoutConstraint *overDateBottom = [NSLayoutConstraint constraintWithItem:_introDetailLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-20];
[self.contentView addConstraint:overDateBottom];
}
return _introDetailLabel;
}
@end
//
// InspectDetailFooterView.h
// redstar
//
// Created by admin on 15/11/4.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TakePhotoView.h"
@interface InspectDetailFooterView : UIView
@property (nonatomic, strong) TakePhotoView *takePhotoView;
@property (nonatomic, strong) UIButton *reportBtn;
@end
//
// InspectDetailFooterView.m
// redstar
//
// Created by admin on 15/11/4.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "InspectDetailFooterView.h"
#define kPictureX 20
#define kPictureY 0
#define kPictureWidth (kScreenWidth - kPictureX * 2)
#define kPictureHeight 40
#define kTakePhotoX 0
#define kTakePhotoY kPictureY + kPictureHeight
#define kTakePhotoWidth (kScreenWidth - kTakePhotoX * 2)
#define kTakePhotoHeight 130 // 待处理
#define kIntroX kPictureX
#define kIntroY kTakePhotoY + kTakePhotoHeight
#define kIntroWidth kPictureWidth
#define kIntroHeight kPictureHeight
#define kBackImageX kPictureX
#define kBackImageY kIntroY + kIntroHeight
#define kBackImageWidth kIntroWidth
#define kBackImageHeight 75
#define kReportX kPictureX
#define kReportY kBackImageY + kBackImageHeight + 20
#define kReportWidth kBackImageWidth
#define kReportHeight 50
#define kFootViewHeight kReportY + kReportHeight + 20
@interface InspectDetailFooterView () <UITextViewDelegate>
@property (nonatomic, strong) UILabel *pictureLabel;
@property (nonatomic, strong) UILabel *introLabel;
@property (nonatomic, strong) UITextView *contentTextView;
@property (nonatomic, strong) UIImageView *backImageView2;
@property (nonatomic, strong) UILabel *placeholderLabel2;
@end
@implementation InspectDetailFooterView
- (instancetype)init
{
self = [super init];
if (self) {
[self setup];
self.backgroundColor = kSectionBackGroundColor;
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setup];
}
return self;
}
- (void)setup {
self.pictureLabel.text = @"现场照片";
self.takePhotoView.backgroundColor = kSectionBackGroundColor;
self.introLabel.text = @"处理说明";
UIImage *image = [UIImage imageNamed:@"textbox"];
UIImage *resizingName = [image resizableImageWithCapInsets:UIEdgeInsetsMake(2, 2, 22, 22) resizingMode:UIImageResizingModeStretch];
self.backImageView2.image = resizingName;
self.contentTextView.backgroundColor = [UIColor clearColor];
self.placeholderLabel2.text = @"请在此输入文字...";
[self.reportBtn setTitle:@"上报结果" forState:UIControlStateNormal];
self.width = kScreenWidth;
self.height = kFootViewHeight;
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if (![text isEqualToString:@""]) {
_placeholderLabel2.hidden = YES;
}
if ([text isEqualToString:@""] && range.location == 0 && range.length == 1) {
_placeholderLabel2.hidden = NO;
}
return YES;
}
- (UILabel *)pictureLabel
{
if (!_pictureLabel) {
_pictureLabel = [[UILabel alloc] initWithFrame:CGRectMake(kPictureX, kPictureY, kPictureWidth, kPictureHeight)];
_pictureLabel.font = [UIFont systemFontOfSize:15.0];
_pictureLabel.textColor = kLightBlack;
[self addSubview:_pictureLabel];
}
return _pictureLabel;
}
- (TakePhotoView *)takePhotoView
{
if (!_takePhotoView) {
_takePhotoView = [[TakePhotoView alloc] initWithFrame:CGRectMake(kTakePhotoX, kTakePhotoY, kTakePhotoWidth, kTakePhotoHeight)];
[self addSubview:_takePhotoView];
}
return _takePhotoView;
}
- (UILabel *)introLabel
{
if (!_introLabel) {
_introLabel = [[UILabel alloc] initWithFrame:CGRectMake(kIntroX, kIntroY, kIntroWidth, kIntroHeight)];
_introLabel.font = [UIFont systemFontOfSize:15.0];
_introLabel.textColor = kLightBlack;
[self addSubview:_introLabel];
}
return _introLabel;
}
- (UIImageView *)backImageView2
{
if (!_backImageView2) {
_backImageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(kBackImageX, kBackImageY, kBackImageWidth, kBackImageHeight)];
_backImageView2.userInteractionEnabled = YES;
[self addSubview:_backImageView2];
}
return _backImageView2;
}
- (UITextView *)contentTextView
{
if (!_contentTextView) {
_contentTextView = [[UITextView alloc] init];
_contentTextView.font = [UIFont systemFontOfSize:15.0];
_contentTextView.delegate = self;
_contentTextView.translatesAutoresizingMaskIntoConstraints = NO;
[self.backImageView2 addSubview:_contentTextView];
NSLayoutConstraint *contentTop = [NSLayoutConstraint constraintWithItem:_contentTextView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.backImageView2 attribute:NSLayoutAttributeTop multiplier:1.0 constant:1];
[self.backImageView2 addConstraint:contentTop];
NSLayoutConstraint *contentLeft = [NSLayoutConstraint constraintWithItem:_contentTextView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.backImageView2 attribute:NSLayoutAttributeLeft multiplier:1.0 constant:1];
[self.backImageView2 addConstraint:contentLeft];
NSLayoutConstraint *contentRight = [NSLayoutConstraint constraintWithItem:_contentTextView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.backImageView2 attribute:NSLayoutAttributeRight multiplier:1.0 constant:-1];
[self.backImageView2 addConstraint:contentRight];
NSLayoutConstraint *contentHeight = [NSLayoutConstraint constraintWithItem:_contentTextView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.backImageView2 attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-1];
[self.backImageView2 addConstraint:contentHeight];
}
return _contentTextView;
}
- (UILabel *)placeholderLabel2
{
if (!_placeholderLabel2) {
_placeholderLabel2 = [[UILabel alloc] init];
_placeholderLabel2.translatesAutoresizingMaskIntoConstraints = NO;
_placeholderLabel2.font = [UIFont systemFontOfSize:15.0];
_placeholderLabel2.textColor = kOnLineCellDetailColor;
[self.contentTextView addSubview:_placeholderLabel2];
NSLayoutConstraint *contentTop = [NSLayoutConstraint constraintWithItem:_placeholderLabel2 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentTextView attribute:NSLayoutAttributeTop multiplier:1.0 constant:2];
[self.contentTextView addConstraint:contentTop];
NSLayoutConstraint *contentLeft = [NSLayoutConstraint constraintWithItem:_placeholderLabel2 attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentTextView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:5];
[self.contentTextView addConstraint:contentLeft];
NSLayoutConstraint *contentRight = [NSLayoutConstraint constraintWithItem:_placeholderLabel2 attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentTextView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.contentTextView addConstraint:contentRight];
NSLayoutConstraint *contentHeight = [NSLayoutConstraint constraintWithItem:_placeholderLabel2 attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:30];
[self.contentTextView addConstraint:contentHeight];
}
return _placeholderLabel2;
}
- (UIButton *)reportBtn
{
if (!_reportBtn) {
_reportBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_reportBtn.frame = CGRectMake(kReportX, kReportY, kReportWidth, kReportHeight);
_reportBtn.titleLabel.font = [UIFont systemFontOfSize:20.0];
_reportBtn.backgroundColor = kNavigationBarColor;
_reportBtn.layer.cornerRadius = 5.0;
_reportBtn.layer.masksToBounds = YES;
[_reportBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[self addSubview:_reportBtn];
}
return _reportBtn;
}
@end
//
// TakePhotoView.h
// redstar
//
// Created by admin on 15/11/4.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface TakePhotoView : UIView <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
{
// 标识被编辑的按钮 -1 为添加新的按钮
NSInteger editTag;
}
@property (nonatomic, strong) UIButton *btn;
@property (nonatomic, assign) NSInteger editTag;
- (BOOL)deleClose:(UIButton *)btn;
@end
//
// TakePhotoView.m
// redstar
//
// Created by admin on 15/11/4.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "TakePhotoView.h"
#define imageH 110 // 图片高度
#define imageW (kScreenWidth - 3 * 20) / 2 // 图片宽度
#define kMaxColumn 2 // 每行显示数量
#define MaxImageCount 9 // 最多显示图片个数
#define deleImageWH 25 // 删除按钮的宽高
#define kAdeleImage @"close.png" // 删除按钮图片
#define kAddImage @"take_photo_btn" // 添加按钮图片
@interface TakePhotoView ()
@property (nonatomic, strong) NSMutableArray *images;
@end
@implementation TakePhotoView
@synthesize editTag;
// 对所有子控件进行布局
- (void)layoutSubviews
{
[super layoutSubviews];
int count = (int)self.subviews.count;
CGFloat btnW = imageW;
CGFloat btnH = imageH;
CGFloat marginX = 20;
CGFloat marginY = 10;
for (int i = 0; i < count; i++) {
UIButton *btn = self.subviews[i];
CGFloat btnX;
CGFloat btnY;
if (i % 2 == 0) {
btnX = marginX;
int k = (int)floor(i / 2);
btnY = (10 + k * (imageH + marginY));
} else {
btnX = marginX + imageW + marginX;
int k = (int)floor(i / 2);
btnY = (10 + k * (imageH + marginY));
}
btn.frame = CGRectMake(btnX, btnY, btnW, btnH);
}
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.btn = [self createButtonWithImage:[UIImage imageNamed:@"add-photos_btn"] andSeletor:@selector(addNew:)];
_btn.backgroundColor = [UIColor whiteColor];
[self addSubview:_btn];
}
return self;
}
// 根据图片名称或者图片创建一个新的显示控件
- (UIButton *)createButtonWithImage:(id)imageNameOrImage andSeletor : (SEL)selector
{
UIImage *addImage = nil;
if ([imageNameOrImage isKindOfClass:[NSString class]]) {
addImage = [UIImage imageNamed:imageNameOrImage];
}
else if([imageNameOrImage isKindOfClass:[UIImage class]])
{
addImage = imageNameOrImage;
}
UIButton *addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[addBtn setImage:addImage forState:UIControlStateNormal];
// [addBtn addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside];
addBtn.tag = self.subviews.count;
// 添加长按手势,用作删除.加号按钮不添加
if(addBtn.tag != 0) {
UILongPressGestureRecognizer *gester = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
[addBtn addGestureRecognizer:gester];
}
return addBtn;
}
// 添加新的控件
- (void)addNew:(UIButton *)btn
{
// 标识为添加一个新的图片
if (![self deleClose:btn]) {
editTag = -1;
[self callImagePicker];
}
}
// 调用图片选择器
- (void)callImagePicker
{
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil message:@"Unable to find the camera" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
} else {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
picker.videoQuality = UIImagePickerControllerQualityTypeLow;
[self.window.rootViewController presentViewController:picker animated:YES completion:nil];
}
}
// 长按添加删除按钮
- (void)longPress : (UIGestureRecognizer *)gester
{
if (gester.state == UIGestureRecognizerStateBegan)
{
UIButton *btn = (UIButton *)gester.view;
UIButton *dele = [UIButton buttonWithType:UIButtonTypeCustom];
dele.backgroundColor = [UIColor redColor];
dele.bounds = CGRectMake(0, 0, deleImageWH, deleImageWH);
[dele setImage:[UIImage imageNamed:kAdeleImage] forState:UIControlStateNormal];
[dele addTarget:self action:@selector(deletePic:) forControlEvents:UIControlEventTouchUpInside];
dele.frame = CGRectMake(btn.frame.size.width - dele.frame.size.width, 0, dele.frame.size.width, dele.frame.size.height);
[btn addSubview:dele];
[self start : btn];
}
}
// 长按开始抖动
- (void)start : (UIButton *)btn {
double angle1 = -5.0 / 180.0 * M_PI;
double angle2 = 5.0 / 180.0 * M_PI;
CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];
anim.keyPath = @"transform.rotation";
anim.values = @[@(angle1), @(angle2), @(angle1)];
anim.duration = 0.25;
// 动画的重复执行次数
anim.repeatCount = MAXFLOAT;
// 保持动画执行完毕后的状态
anim.removedOnCompletion = NO;
anim.fillMode = kCAFillModeForwards;
[btn.layer addAnimation:anim forKey:@"shake"];
}
// 删除"删除按钮"
- (BOOL)deleClose:(UIButton *)btn
{
if (btn.subviews.count == 2) {
[[btn.subviews lastObject] removeFromSuperview];
[self stop:btn];
return YES;
}
return NO;
}
// 停止抖动
- (void)stop : (UIButton *)btn{
[btn.layer removeAnimationForKey:@"shake"];
}
// 删除图片
- (void)deletePic : (UIButton *)btn
{
[self.images removeObject:[(UIButton *)btn.superview imageForState:UIControlStateNormal]];
[btn.superview removeFromSuperview];
if ([[self.subviews lastObject] isHidden]) {
[[self.subviews lastObject] setHidden:NO];
}
}
// 修改旧的控件
- (void)changeOld:(UIButton *)btn
{
// 标识为修改(tag为修改标识)
if (![self deleClose:btn]) {
editTag = btn.tag;
[self callImagePicker];
}
}
#pragma mark - UIImagePickerController 代理方法
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
//UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
if (editTag == -1) {
// 创建一个新的控件
UIButton *btn = [self createButtonWithImage:image andSeletor:@selector(changeOld:)];
[self insertSubview:btn atIndex:self.subviews.count - 1];
[self.images addObject:image];
if (self.subviews.count - 1 == MaxImageCount) {
[[self.subviews lastObject] setHidden:YES];
}
}
else
{
// 根据tag修改需要编辑的控件
UIButton *btn = (UIButton *)[self viewWithTag:editTag];
int index = (int)[self.images indexOfObject:[btn imageForState:UIControlStateNormal]];
[self.images removeObjectAtIndex:index];
[btn setImage:image forState:UIControlStateNormal];
[self.images insertObject:image atIndex:index];
}
// 退出图片选择控制器
[picker dismissViewControllerAnimated:YES completion:nil];
}
@end
//
// InspectSettleViewController.h
// redstar
//
// Created by admin on 15/11/4.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface InspectSettleViewController : UIViewController
@end
//
// InspectSettleViewController.m
// redstar
//
// Created by admin on 15/11/4.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "InspectSettleViewController.h"
#import "InspectSettleCell.h"
#import "InspectDetailFooterView.h"
#define kInspectSettleCell @"InspectSettleCell"
@interface InspectSettleViewController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) InspectDetailFooterView *footerView;
@end
@implementation InspectSettleViewController
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
[customLab setTextColor:[UIColor whiteColor]];
[customLab setText:@"口碑巡检任务"];
customLab.font = [UIFont boldSystemFontOfSize:19];
self.navigationItem.titleView = customLab;
[self.tableView registerClass:[InspectSettleCell class] forCellReuseIdentifier:kInspectSettleCell];
self.tableView.tableFooterView = self.footerView;
[self.footerView.takePhotoView.btn addTarget:self action:@selector(addNew:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Private Methods
- (void)addNew:(UIButton *)sender
{
if (![self.footerView.takePhotoView deleClose:sender]) {
self.footerView.takePhotoView.editTag = -1;
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil message:@"Unable to find the camera" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
} else {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self.footerView.takePhotoView;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
picker.videoQuality = UIImagePickerControllerQualityTypeLow;
[self presentViewController:picker animated:YES completion:nil];
}
}
}
#pragma mark - TableView Delegate/DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
// cell显示的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
InspectSettleCell *cell=[tableView dequeueReusableCellWithIdentifier:kInspectSettleCell];
if (!cell) {
cell = [[InspectSettleCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kInspectSettleCell];
}
cell.titleLabel.text = @"3:广场吊旗";
cell.titleDetailLabel.text = @"要求图片3张";
cell.introLabel.text = @"参考说明";
cell.introDetailLabel.text = @"字体以简体中文为主;内容贴近活动主题;悬挂牢固,以不影响顾客浏览体验为佳";
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
//// cell的高度
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
// return 200;
//}
// section高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return CGFLOAT_MIN;
}
#pragma mark - lazy loading
- (UITableView *)tableView
{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero];
_tableView.translatesAutoresizingMaskIntoConstraints = NO;
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.showsHorizontalScrollIndicator = NO;
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 150.0;
[self.view addSubview:_tableView];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.view addConstraint:tableTop];
NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.view addConstraint:tableLeft];
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.view addConstraint:tableRight];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:tableBottom];
}
return _tableView;
}
- (InspectDetailFooterView *)footerView
{
if (!_footerView) {
_footerView = [[InspectDetailFooterView alloc] init];
}
return _footerView;
}
@end
...@@ -97,7 +97,12 @@ ...@@ -97,7 +97,12 @@
// cell的点击事件 // cell的点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
InspectListCell *cell = (InspectListCell *)[self tableView:_tableView cellForRowAtIndexPath:indexPath];
InspectTaskViewController *inspectTaskVC = [[InspectTaskViewController alloc] init]; InspectTaskViewController *inspectTaskVC = [[InspectTaskViewController alloc] init];
inspectTaskVC.multiplier = cell.multiplier;
inspectTaskVC.alreadyNumber = cell.alreadyLabel.text;
inspectTaskVC.allNumber = cell.allLabel.text;
inspectTaskVC.progressState = cell.progressState;
[self.navigationController pushViewController:inspectTaskVC animated:YES]; [self.navigationController pushViewController:inspectTaskVC animated:YES];
} }
......
//
// InspectTaskDetailCell.h
// redstar
//
// Created by admin on 15/11/3.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "InspectListCell.h"
@interface InspectTaskDetailCell : UITableViewCell
@property (nonatomic, strong) UILabel *shopnameLabel; // 商店名称
@property (nonatomic, strong) UILabel *startDateLabel; // 起始时间
@property (nonatomic, strong) UILabel *overDateLabel; // 截止时间
@property (nonatomic, strong) UILabel *progressLabel; // 完成进度
@property (nonatomic, strong) UILabel *alreadyLabel;
@property (nonatomic, strong) UILabel *allLabel;
@property (nonatomic, assign) ProgressState progressState;
@property (nonatomic, assign) CGFloat multiplier;
@property (nonatomic, strong) UIButton *unfoldBtn;
@property (nonatomic, strong) UIImageView *arrowImageView;
@property (nonatomic, strong) UILabel *dayLabel; // 剩余天数
@end
//
// InspectTaskSortCell.h
// redstar
//
// Created by admin on 15/11/3.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface InspectTaskSortCell : UITableViewCell
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *alreadyLabel;
@property (nonatomic, strong) UILabel *allLabel;
@property (nonatomic, strong) UIImageView *arrowImageView;
@end
//
// InspectTaskSortCell.m
// redstar
//
// Created by admin on 15/11/3.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "InspectTaskSortCell.h"
@implementation InspectTaskSortCell
#pragma mark - System Methods
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self setup];
}
return self;
}
#pragma mark Private Methods
- (void)setup {
self.arrowImageView.backgroundColor = [UIColor orangeColor];
}
- (UILabel *)titleLabel
{
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
_titleLabel.font = [UIFont systemFontOfSize:17.0];
_titleLabel.textColor = kLightBlack;
[self.contentView addSubview:_titleLabel];
NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.contentView addConstraint:overDateTop];
NSLayoutConstraint *overDateLeft = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:overDateLeft];
NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.alreadyLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.contentView addConstraint:overDateRight];
NSLayoutConstraint *overDateBottom = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:overDateBottom];
NSLayoutConstraint *overDateWidth = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:85];
[self.contentView addConstraint:overDateWidth];
}
return _titleLabel;
}
- (UILabel *)alreadyLabel
{
if (!_alreadyLabel) {
_alreadyLabel = [[UILabel alloc] init];
_alreadyLabel.translatesAutoresizingMaskIntoConstraints = NO;
_alreadyLabel.font = [UIFont systemFontOfSize:17.0];
_alreadyLabel.textColor = kLightBlack;
_alreadyLabel.textAlignment = NSTextAlignmentRight;
[self.contentView addSubview:_alreadyLabel];
NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_alreadyLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.contentView addConstraint:overDateTop];
NSLayoutConstraint *overDateWidth = [NSLayoutConstraint constraintWithItem:_alreadyLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:32];
[self.contentView addConstraint:overDateWidth];
NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_alreadyLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.allLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.contentView addConstraint:overDateRight];
NSLayoutConstraint *overDateBottom = [NSLayoutConstraint constraintWithItem:_alreadyLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:overDateBottom];
}
return _alreadyLabel;
}
- (UILabel *)allLabel
{
if (!_allLabel) {
_allLabel = [[UILabel alloc] init];
_allLabel.translatesAutoresizingMaskIntoConstraints = NO;
_allLabel.font = [UIFont systemFontOfSize:17.0];
_allLabel.textColor = kLightBlack;
[self.contentView addSubview:_allLabel];
NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_allLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.contentView addConstraint:overDateTop];
NSLayoutConstraint *overDateWidth = [NSLayoutConstraint constraintWithItem:_allLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:32];
[self.contentView addConstraint:overDateWidth];
//
NSLayoutConstraint *overDateBottom = [NSLayoutConstraint constraintWithItem:_allLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:overDateBottom];
}
return _allLabel;
}
- (UIImageView *)arrowImageView
{
if (!_arrowImageView) {
_arrowImageView = [[UIImageView alloc] init];
_arrowImageView.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_arrowImageView];
NSLayoutConstraint *overDateTop = [NSLayoutConstraint constraintWithItem:_arrowImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:17];
[self.contentView addConstraint:overDateTop];
NSLayoutConstraint *overDateWidth = [NSLayoutConstraint constraintWithItem:_arrowImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:15];
[self.contentView addConstraint:overDateWidth];
//
NSLayoutConstraint *overDateRight = [NSLayoutConstraint constraintWithItem:_arrowImageView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:overDateRight];
NSLayoutConstraint *overDateheight = [NSLayoutConstraint constraintWithItem:_arrowImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:15];
[self.contentView addConstraint:overDateheight];
}
return _arrowImageView;
}
@end
...@@ -7,7 +7,11 @@ ...@@ -7,7 +7,11 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "InspectListCell.h"
@interface InspectTaskViewController : UIViewController @interface InspectTaskViewController : UIViewController
@property (nonatomic, assign) ProgressState progressState;
@property (nonatomic, assign) CGFloat multiplier;
@property (nonatomic, strong) NSString *allNumber;
@property (nonatomic, strong) NSString *alreadyNumber;
@end @end
...@@ -7,9 +7,15 @@ ...@@ -7,9 +7,15 @@
// //
#import "InspectTaskViewController.h" #import "InspectTaskViewController.h"
#import "InspectTaskSortCell.h"
#import "InspectTaskDetailCell.h"
#import "InspectSettleViewController.h"
@interface InspectTaskViewController () #define kTaskSortCell @"InspectTaskSortCell"
#define kTaskDetailCell @"InspectTaskDetailCell"
@interface InspectTaskViewController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@end @end
@implementation InspectTaskViewController @implementation InspectTaskViewController
...@@ -22,6 +28,10 @@ ...@@ -22,6 +28,10 @@
[customLab setText:@"口碑巡检任务"]; [customLab setText:@"口碑巡检任务"];
customLab.font = [UIFont boldSystemFontOfSize:19]; customLab.font = [UIFont boldSystemFontOfSize:19];
self.navigationItem.titleView = customLab; self.navigationItem.titleView = customLab;
[self.tableView registerClass:[InspectTaskSortCell class] forCellReuseIdentifier:kTaskSortCell];
[self.tableView registerClass:[InspectTaskDetailCell class] forCellReuseIdentifier:kTaskDetailCell];
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
...@@ -29,6 +39,174 @@ ...@@ -29,6 +39,174 @@
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
} }
#pragma mark - TableView Delegate/DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0) {
return 1;
} else {
return 2;
}
}
// cell显示的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
InspectTaskDetailCell *cell=[tableView dequeueReusableCellWithIdentifier:kTaskDetailCell];
if (!cell) {
cell = [[InspectTaskDetailCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kTaskDetailCell];
}
cell.multiplier = self.multiplier;
cell.progressState = self.progressState;
cell.alreadyLabel.text = self.alreadyNumber;
cell.allLabel.text = self.allNumber;
cell.shopnameLabel.text = @"上海真北店";
cell.startDateLabel.text = @"2015-09-30";
cell.overDateLabel.text = @"2015-09-30";
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.dayLabel.text = @"3";
return cell;
} else {
InspectTaskSortCell *cell=[tableView dequeueReusableCellWithIdentifier:kTaskSortCell];
if (!cell) {
cell = [[InspectTaskSortCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kTaskSortCell];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.titleLabel.text = @"模块--环境";
cell.alreadyLabel.text = @"(10";
cell.allLabel.text = @"/10)";
return cell;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
return;
} else {
InspectSettleViewController *inspectVC = [[InspectSettleViewController alloc] init];
[self.navigationController pushViewController:inspectVC animated:YES];
}
}
// cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
return 200;
} else {
return 50;
}
}
// section高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0) {
return 45;
} else {
return 40;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return CGFLOAT_MIN;
}
// 自定义section
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
// 创建sectionView
UIView *sectionView = [[UIView alloc] init];
sectionView.userInteractionEnabled = YES;
sectionView.backgroundColor = kSectionBackGroundColor;
if (section == 0) {
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
titleLabel.textAlignment = NSTextAlignmentCenter;
titleLabel.textColor = kAnnounceTextColor;
titleLabel.font = [UIFont systemFontOfSize:17.0];
titleLabel.text = @"2015年10月口碑巡检";
[sectionView addSubview:titleLabel];
NSLayoutConstraint *titleLabelTop = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[sectionView addConstraint:titleLabelTop];
NSLayoutConstraint *titleLabelLeft = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[sectionView addConstraint:titleLabelLeft];
NSLayoutConstraint *titleLabelWidth = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[sectionView addConstraint:titleLabelWidth];
NSLayoutConstraint *titleLabelBottom = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[sectionView addConstraint:titleLabelBottom];
} else {
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
titleLabel.textColor = kAnnounceTextColor;
titleLabel.font = [UIFont systemFontOfSize:15.0];
titleLabel.text = @"分类项目";
[sectionView addSubview:titleLabel];
NSLayoutConstraint *titleLabelTop = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[sectionView addConstraint:titleLabelTop];
NSLayoutConstraint *titleLabelLeft = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[sectionView addConstraint:titleLabelLeft];
NSLayoutConstraint *titleLabelWidth = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[sectionView addConstraint:titleLabelWidth];
NSLayoutConstraint *titleLabelBottom = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[sectionView addConstraint:titleLabelBottom];
}
return sectionView;
}
#pragma mark - lazy loading
- (UITableView *)tableView
{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView.translatesAutoresizingMaskIntoConstraints = NO;
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.showsHorizontalScrollIndicator = NO;
[self.view addSubview:_tableView];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.view addConstraint:tableTop];
NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.view addConstraint:tableLeft];
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.view addConstraint:tableRight];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:tableBottom];
}
return _tableView;
}
/* /*
#pragma mark - Navigation #pragma mark - Navigation
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
{ {
[super viewDidLoad]; [super viewDidLoad];
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)]; UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
[customLab setTextColor:[UIColor whiteColor]]; [customLab setTextColor:[UIColor whiteColor]];
[customLab setText:@"首页"]; [customLab setText:@"首页"];
...@@ -53,7 +54,7 @@ ...@@ -53,7 +54,7 @@
{ {
[super viewWillAppear:animated]; [super viewWillAppear:animated];
self.tabBarController.tabBar.hidden = NO;
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
...@@ -83,13 +84,13 @@ ...@@ -83,13 +84,13 @@
// 口碑列表 或口碑排名 // 口碑列表 或口碑排名
- (void)wordOfMouthClick:(UIButton *)sender - (void)wordOfMouthClick:(UIButton *)sender
{ {
InspectListViewController *inspectListVC = [[InspectListViewController alloc] init]; // InspectListViewController *inspectListVC = [[InspectListViewController alloc] init];
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:inspectListVC animated:YES];
// RankingListViewController *rankListVC = [[RankingListViewController alloc] init];
// self.hidesBottomBarWhenPushed = YES; // self.hidesBottomBarWhenPushed = YES;
// [self.navigationController pushViewController:rankListVC animated:YES]; // [self.navigationController pushViewController:inspectListVC animated:YES];
RankingListViewController *rankListVC = [[RankingListViewController alloc] init];
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:rankListVC animated:YES];
} }
// 问题与知识 // 问题与知识
......
...@@ -10,10 +10,7 @@ ...@@ -10,10 +10,7 @@
#import "LoginView.h" #import "LoginView.h"
#import "CustomDropMenuView.h" #import "CustomDropMenuView.h"
#import "HomeViewController.h" #import "RootTabBarController.h"
#import "AnnounceViewController.h"
#import "ChartViewController.h"
#import "MineViewController.h"
#import <AFNetworking.h> #import <AFNetworking.h>
#import "CommonFunc.h" #import "CommonFunc.h"
...@@ -28,6 +25,9 @@ ...@@ -28,6 +25,9 @@
@property (nonatomic, strong) UITableView *dropTableView; @property (nonatomic, strong) UITableView *dropTableView;
@property (nonatomic, strong) CustomDropMenuView *menu; @property (nonatomic, strong) CustomDropMenuView *menu;
@property (nonatomic, strong) RootTabBarController *rootTBC;
@end @end
@implementation LoginViewController @implementation LoginViewController
...@@ -82,7 +82,11 @@ ...@@ -82,7 +82,11 @@
NSDictionary *parameters = @{@"authenticode":@"211534962",@"password":passwordMD5}; NSDictionary *parameters = @{@"authenticode":@"211534962",@"password":passwordMD5};
[session POST:urlStr parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) { [session POST:urlStr parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
if ([responseObject[@"message"] isEqualToString:@"ok"]) { if ([responseObject[@"message"] isEqualToString:@"ok"]) {
[self setupTabbar]; NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
[userDefault setObject:self.loginView.usernameTextFiled.text forKey:@"username"];
[userDefault setObject:self.loginView.passwordTextFiled.text forKey:@"password"];
self.rootTBC = [[RootTabBarController alloc] init];
[self presentViewController:_rootTBC animated:YES completion:nil];
} else { } else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:[NSString stringWithFormat:@"%@", responseObject[@"message"]] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:[NSString stringWithFormat:@"%@", responseObject[@"message"]] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alertView show]; [alertView show];
...@@ -93,36 +97,6 @@ ...@@ -93,36 +97,6 @@
} }
//
- (void)setupTabbar
{
// 跳转到tabbarController
UITabBarController *tabBC = [[UITabBarController alloc] init];
tabBC.delegate = self;
HomeViewController *home=[[HomeViewController alloc]init];
UINavigationController *homeNav = [self setUpOneChildViewController:home title:@"首页" imageName:@"home_unchecked" selImageName:@"home_checked"];
AnnounceViewController *announce = [[AnnounceViewController alloc] init];
UINavigationController *announceNav = [self setUpOneChildViewController:announce title:@"公告" imageName:@"notice_unchecked" selImageName:@"notice_checked"];
ChartViewController *chart = [[ChartViewController alloc] init];
UINavigationController *chartNav = [self setUpOneChildViewController:chart title:@"报表查询" imageName:@"report_unchecked" selImageName:@"report_checked"];
MineViewController *mine = [[MineViewController alloc] init];
mine.tabBarItem.title= @"我的";
mine.tabBarItem.image = [UIImage imageNamed:@"aboutme_unchecked"];
mine.tabBarItem.selectedImage = [[UIImage imageNamed:@"aboutme_checke"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
kNavigationBarColor, NSForegroundColorAttributeName,
nil] forState:UIControlStateSelected];
tabBC.viewControllers = @[homeNav, announceNav, chartNav, mine];
[self presentViewController:tabBC animated:YES completion:nil];
}
// 找回密码 // 找回密码
- (void)retrieveButtonClick:(UIButton *)sender - (void)retrieveButtonClick:(UIButton *)sender
...@@ -136,23 +110,6 @@ ...@@ -136,23 +110,6 @@
NSLog(@"用户注册"); NSLog(@"用户注册");
} }
// 添加一个控制器的属性
- (UINavigationController *)setUpOneChildViewController:(UIViewController *)vc title:(NSString *)title imageName:(NSString *)imageName selImageName:(NSString *)selImageName
{
// 添加TabBar按钮的图片文字
vc.title = title;
vc.tabBarItem.image = [UIImage imageNamed:imageName];
UIImage *selImage = [UIImage imageNamed:selImageName];
selImage = [selImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
vc.tabBarItem.selectedImage = selImage;
// 添加nav
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
[nav.navigationBar setBarTintColor:kNavigationBarColor];
[nav.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
return nav;
}
#pragma mark - TableView Delegate/DataSource #pragma mark - TableView Delegate/DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{ {
...@@ -183,18 +140,6 @@ ...@@ -183,18 +140,6 @@
return 40; return 40;
} }
#pragma mark - UITabBarViewController Delegate
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if ([viewController isKindOfClass:[MineViewController class]]) {
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController];
tabBarController.tabBar.hidden = YES;
[self presentViewController:nav animated:YES completion:nil];
}
}
#pragma mark - UItextField Delegate #pragma mark - UItextField Delegate
- (void)textFieldDidBeginEditing:(UITextField *)textField - (void)textFieldDidBeginEditing:(UITextField *)textField
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
- (void)quitLoginClick:(UIButton *)sender - (void)quitLoginClick:(UIButton *)sender
{ {
NSLog(@"退出登录···"); [self.tabBarController dismissViewControllerAnimated:YES completion:nil];
} }
#pragma mark - TableView Delegate/DataSource #pragma mark - TableView Delegate/DataSource
......
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