Commit 226c765e authored by AvatarC's avatar AvatarC

Merge branch 'develop' of https://git.oschina.net/gomoretech/RedstarIOS into develop_avatar

parents 56673fac eb106734
This diff is collapsed.
......@@ -49,7 +49,7 @@
[self.contentView addConstraint:titleLeft];
// 右边
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.selectLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:65];
[self.contentView addConstraint:titleRight];
// 高度
......@@ -83,8 +83,8 @@
[self.contentView addConstraint:selectRight];
// 右边
// NSLayoutConstraint *selectWidth = [NSLayoutConstraint constraintWithItem:_selectLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:50];
// [self.contentView addConstraint:selectWidth];
NSLayoutConstraint *selectWidth = [NSLayoutConstraint constraintWithItem:_selectLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.titleLabel attribute:NSLayoutAttributeRight multiplier:1.0 constant:5];
[self.contentView addConstraint:selectWidth];
//
// 高度
NSLayoutConstraint *selectBottom = [NSLayoutConstraint constraintWithItem:_selectLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
......
//
// SelectAreaTableCell.h
// redstar
//
// Created by admin on 15/12/15.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CheckBoxButton.h"
#import "AreaModel.h"
@interface SelectAreaTableCell : UITableViewCell
@property (nonatomic, strong) CheckBoxButton *checkBoxButton;
@property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) AreaModel *areaModel;
@end
//
// SelectAreaTableCell.m
// redstar
//
// Created by admin on 15/12/15.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "SelectAreaTableCell.h"
@implementation SelectAreaTableCell
- (CheckBoxButton *)checkBoxButton
{
if (!_checkBoxButton) {
_checkBoxButton = [[CheckBoxButton alloc] init];
[_checkBoxButton setTitleColor:kLightBlack forState:UIControlStateNormal];
[_checkBoxButton setTitleColor:kSelectStoreColor forState:UIControlStateSelected];
_checkBoxButton.titleLabel.font = [UIFont systemFontOfSize:17.0];
_checkBoxButton.translatesAutoresizingMaskIntoConstraints = NO;
[_checkBoxButton setImage:[UIImage imageNamed:@"uncheck_box"] forState:UIControlStateNormal];
[_checkBoxButton setImage:[UIImage imageNamed:@"check_box"] forState:UIControlStateSelected];
_checkBoxButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
_checkBoxButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
_checkBoxButton.imageView.contentMode = UIViewContentModeRight;
_checkBoxButton.titleLabel.contentMode = UIViewContentModeLeft;
[self.contentView addSubview:_checkBoxButton];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:8];
[self.contentView addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:titleLeft];
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:34];
[self.contentView addConstraint:titleHeight];
// 高度
NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-8];
[self.contentView addConstraint:titleBottom];
}
return _checkBoxButton;
}
- (UIImageView *)iconImageView
{
if (!_iconImageView) {
_iconImageView = [[UIImageView alloc] init];
_iconImageView.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_iconImageView];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:23];
[self.contentView addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleWidth = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:13];
[self.contentView addConstraint:titleWidth];
// 右边
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:titleRight];
// 高度
NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:8];
[self.contentView addConstraint:titleBottom];
}
return _iconImageView;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
//
// SelectProvinceTableCell.h
// redstar
//
// Created by admin on 15/12/15.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CheckBoxButton.h"
#import "ProvinceModel.h"
@interface SelectProvinceTableCell : UITableViewCell
@property (nonatomic, strong) CheckBoxButton *checkBoxButton;
@property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) ProvinceModel *provinceModel;
@end
//
// SelectProvinceTableCell.m
// redstar
//
// Created by admin on 15/12/15.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "SelectProvinceTableCell.h"
@implementation SelectProvinceTableCell
- (CheckBoxButton *)checkBoxButton
{
if (!_checkBoxButton) {
_checkBoxButton = [[CheckBoxButton alloc] init];
[_checkBoxButton setTitleColor:kLightBlack forState:UIControlStateNormal];
[_checkBoxButton setTitleColor:kSelectStoreColor forState:UIControlStateSelected];
_checkBoxButton.titleLabel.font = [UIFont systemFontOfSize:17.0];
_checkBoxButton.translatesAutoresizingMaskIntoConstraints = NO;
[_checkBoxButton setImage:[UIImage imageNamed:@"uncheck_box"] forState:UIControlStateNormal];
[_checkBoxButton setImage:[UIImage imageNamed:@"check_box"] forState:UIControlStateSelected];
_checkBoxButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
_checkBoxButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
_checkBoxButton.imageView.contentMode = UIViewContentModeRight;
_checkBoxButton.titleLabel.contentMode = UIViewContentModeLeft;
[self.contentView addSubview:_checkBoxButton];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:8];
[self.contentView addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:50];
[self.contentView addConstraint:titleLeft];
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:30];
[self.contentView addConstraint:titleHeight];
// 高度
NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-8];
[self.contentView addConstraint:titleBottom];
}
return _checkBoxButton;
}
- (UIImageView *)iconImageView
{
if (!_iconImageView) {
_iconImageView = [[UIImageView alloc] init];
_iconImageView.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_iconImageView];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:23];
[self.contentView addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleWidth = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:11];
[self.contentView addConstraint:titleWidth];
// 右边
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:titleRight];
// 高度
NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_iconImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:7.5];
[self.contentView addConstraint:titleBottom];
}
return _iconImageView;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
//
// SelectStoreTableCell.h
// redstar
//
// Created by admin on 15/12/15.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CheckBoxButton.h"
#import "StoreModel.h"
@interface SelectStoreTableCell : UITableViewCell
//@property (nonatomic, strong) UIButton *storeButton1;
//@property (nonatomic, strong) UIButton *storeButton2;
@property (nonatomic, strong) CheckBoxButton *checkBoxButton;
@property (nonatomic, strong) StoreModel *storeModel;
@end
//
// SelectStoreTableCell.m
// redstar
//
// Created by admin on 15/12/15.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "SelectStoreTableCell.h"
@implementation SelectStoreTableCell
//- (UIButton *)storeButton1
//{
// if (!_storeButton1) {
// _storeButton1 = [[UIButton alloc] init];
// _storeButton1.translatesAutoresizingMaskIntoConstraints = NO;
// _storeButton1.backgroundColor = [UIColor lightGrayColor];
// [self.contentView addSubview:_storeButton1];
//
// // 顶端
// NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_storeButton1 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
// [self.contentView addConstraint:titleTop];
//
// // 右边
// NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_storeButton1 attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:-5];
// [self.contentView addConstraint:titleRight];
//
// // 左边
// NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_storeButton1 attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
// [self.contentView addConstraint:titleLeft];
//
// // 高度
// NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_storeButton1 attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
// [self.contentView addConstraint:titleHeight];
//
// // 高度
// NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_storeButton1 attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-5];
// [self.contentView addConstraint:titleBottom];
// }
// return _storeButton1;
//}
//
//- (UIButton *)storeButton2
//{
// if (!_storeButton2) {
// _storeButton2 = [[UIButton alloc] init];
// _storeButton2.translatesAutoresizingMaskIntoConstraints = NO;
// _storeButton2.backgroundColor = [UIColor lightGrayColor];
// [self.contentView addSubview:_storeButton2];
//
// // 顶端
// NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_storeButton2 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
// [self.contentView addConstraint:titleTop];
//
// // 右边
// NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_storeButton2 attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
// [self.contentView addConstraint:titleRight];
//
// // 左边
// NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_storeButton2 attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:5];
// [self.contentView addConstraint:titleLeft];
//
// // 高度
// NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_storeButton2 attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
// [self.contentView addConstraint:titleHeight];
// }
// return _storeButton2;
//}
- (CheckBoxButton *)checkBoxButton
{
if (!_checkBoxButton) {
_checkBoxButton = [[CheckBoxButton alloc] init];
[_checkBoxButton setTitleColor:kLightBlack forState:UIControlStateNormal];
[_checkBoxButton setTitleColor:kSelectStoreColor forState:UIControlStateSelected];
_checkBoxButton.titleLabel.font = [UIFont systemFontOfSize:17.0];
_checkBoxButton.translatesAutoresizingMaskIntoConstraints = NO;
[_checkBoxButton setImage:[UIImage imageNamed:@"uncheck_box"] forState:UIControlStateNormal];
[_checkBoxButton setImage:[UIImage imageNamed:@"check_box"] forState:UIControlStateSelected];
_checkBoxButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
_checkBoxButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
_checkBoxButton.imageView.contentMode = UIViewContentModeRight;
_checkBoxButton.titleLabel.contentMode = UIViewContentModeLeft;
[self.contentView addSubview:_checkBoxButton];
// 顶端
NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:8];
[self.contentView addConstraint:titleTop];
// 左边
NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:80];
[self.contentView addConstraint:titleLeft];
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:30];
[self.contentView addConstraint:titleHeight];
// 高度
NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_checkBoxButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-8];
[self.contentView addConstraint:titleBottom];
}
return _checkBoxButton;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
//
// SelectYetTableViewCell.h
// redstar
//
// Created by admin on 15/12/21.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol SelectYetDelegate <NSObject>
- (void)removeCurrentWithButton:(UIButton *)sender;
@end
@interface SelectYetTableViewCell : UITableViewCell
@property (nonatomic, strong) NSMutableArray *selectTreeArray;
@property (nonatomic, assign) id <SelectYetDelegate> delegate;
@end
//
// SelectYetTableViewCell.m
// redstar
//
// Created by admin on 15/12/21.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "SelectYetTableViewCell.h"
#import "TreeNodeModel.h"
@implementation SelectYetTableViewCell
- (void)setSelectTreeArray:(NSMutableArray *)selectTreeArray
{
for (UIButton *button in self.contentView.subviews) {
[button removeFromSuperview];
}
_selectTreeArray = selectTreeArray;
for (int i = 0; i < selectTreeArray.count; i++) {
TreeNodeModel *model = selectTreeArray[i];
UIButton *button = [[UIButton alloc] init];
button.tag = 6666687 + i;
button.translatesAutoresizingMaskIntoConstraints = NO;
[button setTitle:model.name forState:UIControlStateNormal];
button.titleLabel.font = [UIFont systemFontOfSize:14.0];
button.backgroundColor = kSelectStoreColor;
button.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 8);
[self.contentView addSubview:button];
CGFloat x,y;
CGFloat marginX = 5;
CGFloat marginY = 5;
CGFloat w = (kScreenWidth - 80) / 2 - marginX;
CGFloat h = 25;
NSInteger row;
if ((i + 1) % 2 == 0) {
x = -20;
row = (i - 1) / 2;
y = 10 + (i / 2) * (h + marginY);
NSLayoutConstraint *imageViewRight = [NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:x];
[self.contentView addConstraint:imageViewRight];
} else {
x = 60;
row = i / 2;
y = 10 + (i / 2) * (h + marginY);
NSLayoutConstraint *imageViewLeft = [NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:x];
[self.contentView addConstraint:imageViewLeft];
}
NSLayoutConstraint *imageViewTop = [NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:y];
[self.contentView addConstraint:imageViewTop];
NSLayoutConstraint *imageViewHeight = [NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:h];
[self.contentView addConstraint:imageViewHeight];
NSLayoutConstraint *imageViewWidth = [NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:w];
[self.contentView addConstraint:imageViewWidth];
if (i == (_selectTreeArray.count - 1)) {
NSLayoutConstraint *imageViewBootom = [NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-5];
[self.contentView addConstraint:imageViewBootom];
}
// 删除按钮
UIButton *deleteBtn = [[UIButton alloc] init];
deleteBtn.translatesAutoresizingMaskIntoConstraints = NO;
[deleteBtn setImage:[UIImage imageNamed:@"delete_box"] forState:UIControlStateNormal];
[deleteBtn addTarget:self action:@selector(deleteBox:) forControlEvents:UIControlEventTouchUpInside];
[button addSubview:deleteBtn];
NSLayoutConstraint *deleteTop = [NSLayoutConstraint constraintWithItem:deleteBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:button attribute:NSLayoutAttributeTop multiplier:1.0 constant:3];
[button addConstraint:deleteTop];
NSLayoutConstraint *deleteHeight = [NSLayoutConstraint constraintWithItem:deleteBtn attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:7.5];
[button addConstraint:deleteHeight];
NSLayoutConstraint *deleteWidth = [NSLayoutConstraint constraintWithItem:deleteBtn attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:7.5];
[button addConstraint:deleteWidth];
NSLayoutConstraint *deleteRight = [NSLayoutConstraint constraintWithItem:deleteBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:button attribute:NSLayoutAttributeRight multiplier:1.0 constant:-3];
[button addConstraint:deleteRight];
}
}
- (void)deleteBox:(UIButton *)sender
{
if (_delegate && [_delegate respondsToSelector:@selector(removeCurrentWithButton:)]) {
[_delegate removeCurrentWithButton:sender];
}
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
}
@end
//
// TreeNodeCell.h
// redstar
//
// Created by admin on 15/12/18.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TreeNodeModel.h"
#import "CheckBoxButton.h"
@class TreeNodeCell;
@protocol TreeNodeDelegate <NSObject>
@optional
/**
* @brief 将要点击折叠图标,返回YES将执行,返回NO取消执行
* @param tree 所在树
* @return YES-执行折叠展开操作,NO-不执行折叠展开操作
*/
-(BOOL)shouldClickFoldButtonAtNode:(TreeNodeCell *)node;
/**
* @brief 点击折叠图标后要执行的操作
* @param node 所在节点
* @return void
*/
-(void)didClickFoldButtonAtNode:(TreeNodeCell *)node;
/**
* @brief 点击标题后要执行的操作
* @param node 所在节点
* @return void
*/
-(void)didClickTitleAtNode:(TreeNodeCell *)node;
@end
@interface TreeNodeCell : UITableViewCell
@property (nonatomic, weak) TreeNodeModel *nodeData;
@property (nonatomic, weak) id<TreeNodeDelegate> nodeDelegate;
@property (nonatomic) UIButton *foldButton;
@property (nonatomic) CheckBoxButton *titleButton;
@end
//
// TreeNodeCell.m
// redstar
//
// Created by admin on 15/12/18.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "TreeNodeCell.h"
#import "CheckBoxButton.h"
@interface TreeNodeCell ()
@end
@implementation TreeNodeCell
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
#pragma mark - 初始化函数
-(instancetype)init {
self = [super init];
if (self) {
[self configSelf];
}
return self;
}
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self configSelf];
}
return self;
}
-(instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self configSelf];
}
return self;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self configSelf];
}
return self;
}
-(void)configSelf {
}
#pragma mark - 属性
-(void)setNodeData:(TreeNodeModel *)nodeData {
_nodeData = nodeData;
[self configFoldButton];
[self configTitleButton];
}
#pragma mark - 折叠按钮
- (void)configFoldButton {
if (self.foldButton == nil) {
self.foldButton = [UIButton buttonWithType:UIButtonTypeCustom];
_foldButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.foldButton addTarget:self action:@selector(actionFoldButton:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:self.foldButton];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_foldButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.contentView addConstraint:tableTop];
NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_foldButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.contentView addConstraint:tableLeft];
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_foldButton attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.contentView addConstraint:tableRight];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_foldButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:tableBottom];
NSLayoutConstraint *tableHeight = [NSLayoutConstraint constraintWithItem:_foldButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:50];
[self.contentView addConstraint:tableHeight];
}
self.foldButton.selected = self.nodeData.expand;
}
-(void)actionFoldButton:(UIButton *)sender {
if ([self.nodeDelegate respondsToSelector:@selector(shouldClickFoldButtonAtNode:)]) {
if ([self.nodeDelegate shouldClickFoldButtonAtNode:self] == NO) {
return;
}
}
sender.selected = ! sender.selected;
self.nodeData.expand = sender.selected;
if ([self.nodeDelegate respondsToSelector:@selector(didClickFoldButtonAtNode:)]) {
[self.nodeDelegate didClickFoldButtonAtNode:self];
}
}
#pragma mark - 标题按钮
-(void)configTitleButton {
[self.titleButton removeFromSuperview];
self.titleButton = [[CheckBoxButton alloc] init];
_titleButton.translatesAutoresizingMaskIntoConstraints = NO;
self.titleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[self.titleButton addTarget:self action:@selector(actionTitleButton:) forControlEvents:UIControlEventTouchUpInside];
[_titleButton setImage:[UIImage imageNamed:@"uncheck_box"] forState:UIControlStateNormal];
[_titleButton setImage:[UIImage imageNamed:@"check_box"] forState:UIControlStateSelected];
[self.titleButton setTitle:self.nodeData.name forState:UIControlStateNormal];
[self.titleButton setTitleColor:kLightBlack forState:UIControlStateNormal];
[self.titleButton setTitleColor:kSelectStoreColor forState:UIControlStateSelected];
self.titleButton.titleLabel.font = [UIFont systemFontOfSize:16.0];
[self addSubview:self.titleButton];
//CGFloat x = 20 + self.nodeData.levelDeep * 22;
CGFloat x = self.nodeData.levelDeep * 22;
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_titleButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self addConstraint:tableTop];
NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_titleButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:x];
[self addConstraint:tableLeft];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_titleButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self addConstraint:tableBottom];
}
-(void)actionTitleButton:(UIButton *)sender {
if ([self.nodeDelegate respondsToSelector:@selector(didClickTitleAtNode:)]) {
[self.nodeDelegate didClickTitleAtNode:self];
}
}
@end
//
// AreaModel.h
// redstar
//
// Created by admin on 15/12/13.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface AreaModel : NSObject
@property (nonatomic, copy) NSString *name;
@property (nonatomic, strong) NSArray *provinceArray;
@property (nonatomic, assign) BOOL isChoose;
- (id)initWithName:(NSString *)name children:(NSArray *)children;
+ (id)dataObjectWithName:(NSString *)name children:(NSArray *)children;
@end
//
// AreaModel.m
// redstar
//
// Created by admin on 15/12/13.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "AreaModel.h"
@implementation AreaModel
- (id)initWithName:(NSString *)name children:(NSArray *)children
{
self = [super init];
if (self) {
self.provinceArray = [NSArray arrayWithArray:children];
self.name = name;
}
return self;
}
+ (id)dataObjectWithName:(NSString *)name children:(NSArray *)children
{
return [[self alloc] initWithName:name children:children];
}
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
//
// ProvinceModel.h
// redstar
//
// Created by admin on 15/12/13.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface ProvinceModel : NSObject
@property (nonatomic, copy) NSString *name;
@property (nonatomic, strong) NSArray *storeArray;
@property (nonatomic, assign) BOOL isChoose;
- (id)initWithName:(NSString *)name children:(NSArray *)children;
+ (id)dataObjectWithName:(NSString *)name children:(NSArray *)children;
@end
//
// ProvinceModel.m
// redstar
//
// Created by admin on 15/12/13.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "ProvinceModel.h"
@implementation ProvinceModel
- (id)initWithName:(NSString *)name children:(NSArray *)children
{
self = [super init];
if (self) {
self.storeArray = [NSArray arrayWithArray:children];
self.name = name;
}
return self;
}
+ (id)dataObjectWithName:(NSString *)name children:(NSArray *)children
{
return [[self alloc] initWithName:name children:children];
}
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
//
// StoreModel.h
// redstar
//
// Created by admin on 15/12/13.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface StoreModel : NSObject
@property (nonatomic, copy) NSString *name;
@property (nonatomic, assign) BOOL isChoose;
- (id)initWithName:(NSString *)name;
+ (id)dataObjectWithName:(NSString *)name;
@end
//
// StoreModel.m
// redstar
//
// Created by admin on 15/12/13.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "StoreModel.h"
@implementation StoreModel
- (id)initWithName:(NSString *)name
{
self = [super init];
if (self) {
self.name = name;
}
return self;
}
+ (id)dataObjectWithName:(NSString *)name
{
return [[self alloc] initWithName:name];
}
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
@end
//
// TreeNodeModel.h
// redstar
//
// Created by admin on 15/12/18.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TreeNodeModel : NSObject
@property (nonatomic, copy) NSString *code;
/// 节点名称
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *path;
@property (nonatomic, copy) NSString *upper;
@property (nonatomic, copy) NSString *uuid;
@property (nonatomic, assign) int level;
@property (nonatomic) BOOL isChoose;
/// 层级
@property (nonatomic, readonly) int levelDeep;
/// 节点是否展开
@property (nonatomic, getter=isExpand) BOOL expand;
/// 节点数,如果节点折叠则只算一个
@property (nonatomic, readonly) NSUInteger nodeCount;
/// 孩子节点
@property (nonatomic, readonly) NSMutableArray *child;
/// 父节点
@property (nonatomic, weak, readonly) TreeNodeModel *parent;
/// 兄弟节点
@property (nonatomic, weak, readonly) TreeNodeModel *brother;
-(instancetype)initWithName:(NSString *)name;
/**
* @brief 用于遍历时返回下一个展开的节点。
* @detail 如果自己是展开的并且有子节点,则返回第一个子节点;否则返回下一个兄弟节点,如果没有兄弟节点则递归往上返回父节点的兄弟节点,直至到根节点
* @return 下一个节点数据
*/
-(TreeNodeModel *)nextNode;
/**
* @brief 返回需要显示的节点数组
* @param includeRoot 是否包含根节点
* @return 节点数组
*/
-(NSArray*)nodeArray:(BOOL)includeRoot;
/**
* @brief 在最后位置插入一个子节点
* @param node 要插入的节点
* @return void
*/
-(void)insertChild:(TreeNodeModel *)node;
/**
* @brief 在指定位置插入一个子节点,如果indexes大于子节点数则插入在最后位置
* @param node 要插入的节点
* @param indexes 插入的位置
* @return void
*/
-(void)insertChild:(TreeNodeModel *)node index:(NSUInteger)indexes;
/**
* @brief 移除一个子节点
* @param node 要移除的子节点
* @return YES-成功移除,NO-移除失败(没有找到此子节点)
*/
-(BOOL)removeChild:(TreeNodeModel *)node;
/**
* @brief 移除指定位置的子节点
* @param indexes 要移除的子节点的索引
* @return YES-成功移除,NO-移除失败(不是有效索引)
*/
-(BOOL)removeChildAtIndexes:(NSUInteger)indexes;
/**
* @brief 根节点
*/
-(TreeNodeModel *)rootNode;
/**
* @brief 清除所有子节点
* @return void
*/
-(void)clear;
@end
//
// TreeNodeModel.m
// redstar
//
// Created by admin on 15/12/18.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "TreeNodeModel.h"
@interface TreeNodeModel ()
/// 层级
@property (nonatomic) int levelDeep;
/// 孩子节点
@property (nonatomic) NSMutableArray *child;
/// 父节点
@property (nonatomic, weak) TreeNodeModel *parent;
/// 兄弟节点
@property (nonatomic, weak) TreeNodeModel *brother;
@end
@implementation TreeNodeModel
- (instancetype)init {
self = [super init];
if (self) {
[self configSelf];
}
return self;
}
-(instancetype)initWithName:(NSString *)name {
self = [super init];
if (self) {
[self configSelf];
self.name = name;
}
return self;
}
-(void)configSelf {
self.expand = NO;
self.levelDeep = 0;
self.child = [NSMutableArray array];
self.parent = nil;
self.brother = nil;
}
-(NSUInteger)nodeCount {
NSUInteger count = 1;
if (self.isExpand) {
for (TreeNodeModel* node in self.child) {
count += node.nodeCount;
}
}
return count;
}
-(TreeNodeModel *)nextNode {
if (self.isExpand && self.child.count != 0) {
return self.child[0];
}
else {
for (TreeNodeModel *node = self; node != nil; node = node.parent) {
if (node.brother != nil) {
return node.brother;
}
}
return nil;
}
}
-(NSArray *)nodeArray:(BOOL)includeRoot {
NSMutableArray *array = [NSMutableArray array];
if (includeRoot) {
[array addObject:self];
for (TreeNodeModel *node = [self nextNode]; node != nil && node.levelDeep > self.levelDeep; node = [node nextNode]) {
[array addObject:node];
}
}
else {
if (self.child.count != 0) {
for (TreeNodeModel *node = self.child[0]; node != nil && node.levelDeep > self.levelDeep; node = [node nextNode]) {
[array addObject:node];
}
}
}
return [NSArray arrayWithArray:array];
}
-(void)insertChild:(TreeNodeModel *)node {
node.levelDeep = self.levelDeep + 1;
node.parent = self;
node.brother = nil;
if (self.child.count > 0) {
((TreeNodeModel*)self.child[self.child.count - 1]).brother = node;
}
[self.child addObject:node];
}
-(void)insertChild:(TreeNodeModel *)node index:(NSUInteger)indexes {
if (indexes >= self.child.count) {
indexes = self.child.count - 1;
}
node.levelDeep = self.levelDeep + 1;
node.parent = self;
node.brother = self.child[indexes];
if (indexes > 0) {
((TreeNodeModel*)self.child[indexes - 1]).brother = node;
}
[self.child insertObject:node atIndex:indexes];
}
-(BOOL)removeChild:(TreeNodeModel *)node {
for (int i = 0; i < self.child.count; i++) {
if ([node isEqual:self.child[i]]) {
return [self removeChildAtIndexes:i];
}
}
return NO;
}
-(BOOL)removeChildAtIndexes:(NSUInteger)indexes {
if (indexes < self.child.count) {
if (indexes > 0) {
if (indexes < self.child.count - 1) {
((TreeNodeModel *)self.child[indexes - 1]).brother = self.child[indexes + 1];
}
else {
((TreeNodeModel *)self.child[indexes - 1]).brother = nil;
}
}
[self.child removeObjectAtIndex:indexes];
return YES;
}
else {
return NO;
}
}
- (TreeNodeModel *)rootNode {
TreeNodeModel *node = self;
while (node.parent != nil) {
node = node.parent;
}
return node;
}
-(void)clear {
[self.child removeAllObjects];
}
-(NSString *)description
{
return [NSString stringWithFormat:@"11 level = %d-----22upper: %@ 33 code = %@ 44. levelDeep = %d",self.level, self.upper, self.code, self.levelDeep];
}
- (void)setIsChoose:(BOOL)isChoose
{
_isChoose = isChoose;
// 对当前的父类进行处理
for (TreeNodeModel *model in self.parent.child) {
if (model.isChoose == NO) {
self.parent.isChoose = NO;
break;
} else {
self.parent.isChoose = YES;
}
}
}
@end
//
// TreeView.h
// redstar
//
// Created by admin on 15/12/18.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TreeNodeModel.h"
#import "TreeNodeCell.h"
@class TreeView;
@protocol TreeDelegate <NSObject>
@optional
/**
* @brief 将要点击折叠图标,返回YES将执行,返回NO取消执行
* @param tree 所在树
* @param node 所在节点
* @return YES-执行折叠展开操作,NO-不执行折叠展开操作
*/
-(BOOL)tree:(TreeView *)tree shouldClickFoldButtonAtNode:(TreeNodeCell *)node;
/**
* @brief 点击折叠图标后要执行的操作
* @param tree 所在树
* @param node 所在节点
* @return void
*/
-(void)tree:(TreeView *)tree didClickFoldButtonAtNode:(TreeNodeCell *)node;
/**
* @brief 点击标题后要执行的操作
* @param tree 所在树
* @param node 所在节点
* @return void
*/
-(void)tree:(TreeView *)tree didClickTitleAtNode:(TreeNodeCell *)node;
@end
@interface TreeView : UITableView<UITableViewDelegate, UITableViewDataSource, TreeNodeDelegate>
/// 节点数据资源
@property (nonatomic) TreeNodeModel *nodeData;
/// 代理
@property (nonatomic, weak) id<TreeDelegate> treeDelegate;
@property (nonatomic, strong) NSMutableArray *selectTreeArray;
@end
//
// TreeView.m
// redstar
//
// Created by admin on 15/12/18.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "TreeView.h"
#import "TreeNodeCell.h"
#import "SelectYetTableViewCell.h"
@interface TreeView () <SelectYetDelegate>
@property (nonatomic) NSArray *nodeArray;
@end
@implementation TreeView
#pragma mark - 初始化函数
-(instancetype)init {
self = [super init];
if (self) {
[self configSelf];
}
return self;
}
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self configSelf];
}
return self;
}
-(instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self configSelf];
}
return self;
}
-(instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
self = [super initWithFrame:frame style:style];
if (self) {
[self configSelf];
}
return self;
}
-(void)configSelf {
self.dataSource = self;
self.delegate = self;
self.rowHeight = UITableViewAutomaticDimension;
self.estimatedRowHeight = 50.0;
}
#pragma mark - SelectYetDelegate
- (void)removeCurrentWithButton:(UIButton *)sender
{
UIButton *button = (UIButton *)sender.superview;
NSInteger index = button.tag - 6666687;
TreeNodeModel *treeM = _selectTreeArray[index];
treeM.isChoose = NO;
[button removeFromSuperview];
button = nil;
[self.selectTreeArray removeObject:treeM];
[self reloadData];
}
#pragma mark - 表格代理
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
self.nodeArray = [self.nodeData nodeArray:NO];
return self.nodeArray.count + 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
SelectYetTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"11nodeCell"];
if (cell == nil) {
cell = [[SelectYetTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"11nodeCell"];
}
cell.delegate = self;
cell.selectTreeArray = self.selectTreeArray;
cell.textLabel.text = @"已选:";
cell.textLabel.textColor = kLightGray;
cell.textLabel.font = [UIFont systemFontOfSize:15.0];
return cell;
} else {
TreeNodeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"nodeCell"];
if (cell == nil) {
cell = [[TreeNodeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"nodeCell"];
}
cell.nodeDelegate = self;
cell.nodeData = self.nodeArray[indexPath.row - 1];
// 强制刷新,主要是为了刷新那些自画线条
cell.titleButton.selected = cell.nodeData.isChoose;
[cell setNeedsDisplay];
return cell;
}
}
#pragma mark - node代理
-(BOOL)shouldClickFoldButtonAtNode:(TreeNodeCell *)node {
if ([self.treeDelegate respondsToSelector:@selector(tree:shouldClickFoldButtonAtNode:)]) {
return [self.treeDelegate tree:self shouldClickFoldButtonAtNode:node];
}
else {
return YES;
}
}
-(void)didClickFoldButtonAtNode:(TreeNodeCell *)node {
// 获取变动的行索引
NSUInteger beginIndex = [self.nodeArray indexOfObject:node.nodeData] + 2;
NSUInteger indexCount = [[node.nodeData nodeArray:NO] count];
NSMutableArray *indexArray = [NSMutableArray array];
for (int i = 0; i < indexCount; i++) {
[indexArray addObject:[NSIndexPath indexPathForRow:beginIndex + i inSection:0]];
}
// 用插入和删除函数就会产生动画
if (node.nodeData.isExpand == NO) {
[self deleteRowsAtIndexPaths:indexArray withRowAnimation:(UITableViewRowAnimationTop)];
}
else {
[self insertRowsAtIndexPaths:indexArray withRowAnimation:(UITableViewRowAnimationBottom)];
}
if (beginIndex == 1) {
[node setNeedsDisplay];
}
if ([self.treeDelegate respondsToSelector:@selector(tree:didClickFoldButtonAtNode:)]) {
[self.treeDelegate tree:self didClickFoldButtonAtNode:node];
}
}
- (void)didClickTitleAtNode:(TreeNodeCell *)node {
if ([self.treeDelegate respondsToSelector:@selector(tree:didClickTitleAtNode:)]) {
[self.treeDelegate tree:self didClickTitleAtNode:node];
}
}
@end
......@@ -8,6 +8,12 @@
#import <UIKit/UIKit.h>
@interface SelectStoreViewController : UIViewController
@protocol SelectStoreDelegate <NSObject>
- (void)deliverWithArray:(NSMutableArray *)array;
@end
@interface SelectStoreViewController : UIViewController
@property (nonatomic, assign) id <SelectStoreDelegate> delegate;
@end
//
// AddButtonTableViewCell.h
// redstar
//
// Created by admin on 15/12/19.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AddButtonTableViewCell : UITableViewCell
@property (nonatomic, strong) UIButton *addButton;
@end
//
// AddButtonTableViewCell.m
// redstar
//
// Created by admin on 15/12/19.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "AddButtonTableViewCell.h"
@implementation AddButtonTableViewCell
- (UIButton *)addButton
{
if (!_addButton) {
_addButton = [[UIButton alloc] init];
_addButton.translatesAutoresizingMaskIntoConstraints = NO;
[_addButton setTitle:@"添加图片文字" forState:UIControlStateNormal];
[_addButton setTitleColor:kNavigationBarColor forState:UIControlStateNormal];
_addButton.titleLabel.font = [UIFont systemFontOfSize:15.0];
[self.contentView addSubview:_addButton];
NSLayoutConstraint *contentTop = [NSLayoutConstraint constraintWithItem:_addButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.contentView addConstraint:contentTop];
NSLayoutConstraint *contentLeft = [NSLayoutConstraint constraintWithItem:_addButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:kScreenWidth - 130];
[self.contentView addConstraint:contentLeft];
NSLayoutConstraint *contentRight = [NSLayoutConstraint constraintWithItem:_addButton attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:contentRight];
NSLayoutConstraint *contentHeight = [NSLayoutConstraint constraintWithItem:_addButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:30];
[self.contentView addConstraint:contentHeight];
NSLayoutConstraint *contentBottom = [NSLayoutConstraint constraintWithItem:_addButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:contentBottom];
}
return _addButton;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
//
// AddPicTextTableViewCell.h
// redstar
//
// Created by admin on 15/12/19.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AddPicTextTableViewCell : UITableViewCell
@property (nonatomic, strong) UIButton *photoButton;
@property (nonatomic, strong) UILabel *photoLabel;
@property (nonatomic, strong) UITextView *titleTextView;
@end
......@@ -406,7 +406,6 @@
cell = [[InspectPicAddCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
}
NSString *imageName = _imageNameArray[_imageNameArray.count - 1];
NSLog(@"imageName = %@", imageName);
NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
UIImage *image = [UIImage imageWithContentsOfFile:fullPath];
UIImage *image00 = [self cutImage:image];
......
......@@ -65,7 +65,6 @@
UIImage *image = [UIImage imageNamed:@"progress-bar"];
image = [image resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeTile];
self.alreadyView.image = image;
NSLog(@"taskList = %@", taskList.state);
if ([taskList.state isEqualToString:@"submitted"]) {
NSString *str = [NSString stringWithFormat:@"巡检进度:未处理"];
NSMutableAttributedString *strAttr = [[NSMutableAttributedString alloc] initWithString:str];
......
......@@ -27,7 +27,8 @@
@property (nonatomic, assign) int reportCount;
@property (nonatomic, copy) NSString *reportTime;
@property (nonatomic, copy) NSString *reported;
@property (nonatomic, copy) NSString *score;
//@property (nonatomic, copy) NSString *score;
@property (nonatomic, assign) CGFloat score;
@property (nonatomic, copy) NSString *state;
@property (nonatomic, copy) NSString *store_code;
@property (nonatomic, copy) NSString *store_name;
......
......@@ -58,7 +58,12 @@
self.rankDetailView.totalScoreLabel.text = @"总评分";
self.rankDetailView.totalGradeLabel.text = @"总排名";
self.rankDetailView.timeLabel.text = [NSString stringWithFormat:@"%@", taskDetail.beginDate];
self.rankDetailView.scoreLabel.text = [NSString stringWithFormat:@"%@", taskDetail.score];
//self.rankDetailView.scoreLabel.text = [NSString stringWithFormat:@"%@", taskDetail.score];
if (taskDetail.score == 0) {
self.rankDetailView.scoreLabel.text = [NSString stringWithFormat:@"0"];
} else {
self.rankDetailView.scoreLabel.text = [NSString stringWithFormat:@"%.1f",taskDetail.score];
}
}
......
......@@ -497,7 +497,8 @@
{
if (!_rankDetailHeaderView) {
_rankDetailHeaderView = [[RankDetailHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 298)];
if (self.indexRow < 3) {
NSLog(@"se。row= =%ld", _indexRow);
if (self.indexRow <= 3) {
NSString *imageName = [NSString stringWithFormat:@"medal_0%ld", (long)(_indexRow)];
_rankDetailHeaderView.rankDetailView.gradeImageView.image = [UIImage imageNamed:imageName];
} else {
......
......@@ -33,7 +33,13 @@
{
_rankList = rankList;
self.shopNameButton.text = [NSString stringWithFormat:@"%@", rankList.store_name];
self.scoreLabel.text = [NSString stringWithFormat:@"%@", rankList.score];
//self.scoreLabel.text = [NSString stringWithFormat:@"%@", rankList.score];
if (rankList.score == 0) {
self.scoreLabel.text = [NSString stringWithFormat:@"0"];
} else {
self.scoreLabel.text = [NSString stringWithFormat:@"%.1f", rankList.score];
}
}
......
......@@ -14,7 +14,9 @@
@property (nonatomic,copy) NSString *store_uuid;
@property (nonatomic,copy) NSString *store_code;
@property (nonatomic,copy) NSString *store_name;
@property (nonatomic,copy) NSString * score;
// @property (nonatomic,copy) NSString * score;
@property (nonatomic, assign) CGFloat score;
@property (nonatomic,copy) NSString *reported;
@property (nonatomic,copy) NSString *commentId;
@property (nonatomic,copy) NSString *ranking;
......
......@@ -71,7 +71,8 @@
[self addSubview:scoreLabel];
_scoreLabel = scoreLabel;
if (index < 3) {
if (index <= 3) {
NSLog(@"indec === %d", index);
UIImageView *gradeImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"medal_0%d", index]]];
[self addSubview:gradeImageView];
_gradeImageView = gradeImageView;
......@@ -120,12 +121,19 @@
{
_rankListModel = rankListModel;
[_bgButton setTitle:rankListModel.store_name forState:UIControlStateNormal];
if (rankListModel.score == nil || rankListModel.score == NULL || [rankListModel.score isEqual:[NSNull null]]) {
if (rankListModel.score == 0) {
_scoreLabel.text = [NSString stringWithFormat:@"0"];
} else {
_scoreLabel.text = [NSString stringWithFormat:@"%@",rankListModel.score];
_scoreLabel.text = [NSString stringWithFormat:@"%.1f",rankListModel.score];
}
// if (rankListModel.score == nil || rankListModel.score == NULL || [rankListModel.score isEqual:[NSNull null]]) {
// _scoreLabel.text = [NSString stringWithFormat:@"0"];
// } else {
// _scoreLabel.text = [NSString stringWithFormat:@"%@",rankListModel.score];
// }
}
......
......@@ -26,7 +26,7 @@
#import "SelectStoreViewController.h"
#import "RankPickView.h"
#import "TreeNodeModel.h"
#define konlineCell @"onlinesTableViewCell"
#define kRankingCell @"RankingTableViewCell"
......@@ -34,7 +34,7 @@
#define kRankScreenTableViewCell @"rankingScreenCell"
#define kShopNameBtnTag 15000
@interface RankingListViewController () <UITableViewDataSource, UITableViewDelegate, RankListHeaderDelegate, UIPickerViewDelegate, UIPickerViewDataSource>
@interface RankingListViewController () <UITableViewDataSource, UITableViewDelegate, RankListHeaderDelegate, UIPickerViewDelegate, UIPickerViewDataSource, SelectStoreDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *allRankListArray;
......@@ -54,6 +54,8 @@
@property (nonatomic, strong) NSMutableArray *titleArray;
@property (nonatomic, assign) NSInteger pickRow;
@property (nonatomic, strong) NSMutableArray *uuidArray;
@end
@implementation RankingListViewController
......@@ -63,7 +65,7 @@
[super viewDidLoad];
self.allTitleArray = [NSArray arrayWithObjects:@"口碑巡检", @"选择范围", @"统计方式" ,nil];
self.uuidArray = [NSMutableArray array];
self.titleArray = [NSMutableArray array];
self.tableView.delegate = self;
......@@ -198,6 +200,7 @@
NSDictionary *dict = _titleArray[_pickRow];
NSDictionary *parameters = @{@"praiseUuid":dict[@"uuid"],
@"statisMode":@(statisMode),
@"orgUuids":_uuidArray
};
NSLog(@"parrrrrters = %@", parameters);
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
......@@ -233,7 +236,9 @@
- (NSArray *)sortRankListWithRankListArray:(NSMutableArray *)allRanking
{
NSArray *sortedArray = [allRanking sortedArrayUsingComparator:^NSComparisonResult(RankListModel *p1, RankListModel *p2){
return [p2.score compare:p1.score];
//return [@(p2.score) compare:@(p1.score)];
return [@(p2.score) compare:@(p1.score)];
}];
return sortedArray;
}
......@@ -285,6 +290,18 @@
[self closeBackGroundView];
}
#pragma mark - SelectStoreDelegate
- (void)deliverWithArray:(NSMutableArray *)array
{
NSString *nameStr = @"";
for (TreeNodeModel *model in array) {
nameStr = [nameStr stringByAppendingString:model.name];
[_uuidArray addObject:model.uuid];
}
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:0];
OnLineTableViewCell *cell = (OnLineTableViewCell *)[_tableView cellForRowAtIndexPath:indexPath];
cell.selectLabel.text = nameStr;
}
#pragma mark - UITableView DataSource/Delegate
......@@ -402,6 +419,7 @@
} else if (indexPath.row == 1) {
SelectStoreViewController *select = [[SelectStoreViewController alloc] init];
select.delegate = self;
[self.navigationController pushViewController:select animated:YES];
} else {
return;
......@@ -409,7 +427,7 @@
} else {
RankListModel *rankList = _rankData[indexPath.section - 1];
RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init];
rankDetailVC.indexRow = indexPath.section;
rankDetailVC.indexRow = rankList.index;
rankDetailVC.uuid = rankList.uuid;
rankDetailVC.store_uuid = rankList.store_uuid;
rankDetailVC.storeAddress = rankList.storeAddress;
......@@ -442,6 +460,7 @@
return nil;
} else {
RankListModel *rankList = _rankData[section - 1];
NSLog(@"indeB === %d", rankList.index);
RankListHeaderView *headView = [RankListHeaderView headViewWithTableView:tableView section:section - 1 index:rankList.index];
headView.delegate = self;
[headView.pushButton addTarget:self action:@selector(pushclick:) forControlEvents:UIControlEventTouchUpInside];
......@@ -456,7 +475,7 @@
RankListModel *rankList = _rankData[section];
RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init];
rankDetailVC.indexRow = section - 1;
rankDetailVC.indexRow = rankList.index;
rankDetailVC.uuid = rankList.uuid;
rankDetailVC.store_uuid = rankList.store_uuid;
rankDetailVC.storeAddress = rankList.storeAddress;
......
......@@ -334,7 +334,9 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
- (NSArray *)sortRankListWithRankListArray:(NSMutableArray *)allRanking
{
NSArray *sortedArray = [allRanking sortedArrayUsingComparator:^NSComparisonResult(RankListModel *p1, RankListModel *p2){
return [p2.score compare:p1.score];
//return [p2.score compare:p1.score];
return [@(p2.score) compare:@(p1.score)];
}];
return sortedArray;
}
......
......@@ -259,7 +259,9 @@
- (NSArray *)sortRankListWithRankListArray:(NSMutableArray *)allRanking
{
NSArray *sortedArray = [allRanking sortedArrayUsingComparator:^NSComparisonResult(RankListModel *p1, RankListModel *p2){
return [p2.score compare:p1.score];
// return [p2.score compare:p1.score];
return [@(p2.score) compare:@(p1.score)];
}];
return sortedArray;
}
......
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