add
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
-(void)loadCellData:(NSIndexPath*)indexPath user:(GiGaUser*)user{
|
||||
if (indexPath.section == 2 && indexPath.row == 1) {
|
||||
self.cityLabel.text = @"生日";
|
||||
if (user.birthday && ![user.birthday isKindOfClass:[NSNull class]]) {
|
||||
if (user.birthday && ![user.birthday isKindOfClass:[NSNull class]] && ![user.birthday isEqualToString:@""]) {
|
||||
self.detalTitle.text = user.birthday;
|
||||
}else{
|
||||
self.detalTitle.text = @"选择生日";
|
||||
@@ -26,17 +26,28 @@
|
||||
|
||||
}else if (indexPath.section == 2 && indexPath.row == 2){
|
||||
self.cityLabel.text = @"城市";
|
||||
if (user.cityName && ![user.cityName isKindOfClass:[NSNull class]]) {
|
||||
self.detalTitle.text = user.cityName;
|
||||
}else{
|
||||
if (!user.provinceName || [user.provinceName isKindOfClass:[NSNull class]]) {
|
||||
user.provinceName = @"";
|
||||
}
|
||||
if (!user.cityName || [user.cityName isKindOfClass:[NSNull class]]) {
|
||||
user.cityName = @"";
|
||||
}
|
||||
|
||||
if (!user.areaName || [user.areaName isKindOfClass:[NSNull class]]) {
|
||||
user.areaName = @"";
|
||||
}
|
||||
|
||||
if ([user.provinceName isEqualToString:@""] && [user.provinceName isEqualToString:@""] && [user.provinceName isEqualToString:@""] ) {
|
||||
self.detalTitle.text = @"选择城市";
|
||||
}else{
|
||||
self.detalTitle.text = [NSString stringWithFormat:@"%@%@%@",user.provinceName,user.cityName,user.areaName];
|
||||
}
|
||||
}else if (indexPath.section == 2 && indexPath.row == 3){
|
||||
self.cityLabel.text = @"职业";
|
||||
if (user.occupationCode && ![user.occupationCode isKindOfClass:[NSNull class]]) {
|
||||
if (user.occupationCode && ![user.occupationCode isKindOfClass:[NSNull class]] && ![user.occupationCode isEqualToString:@""]) {
|
||||
self.detalTitle.text = user.occupationCode;
|
||||
}else{
|
||||
self.detalTitle.text = @"选择职业";
|
||||
self.detalTitle.text = @"请从下方标签中选择一项";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// GiGaUserJobViewCell.h
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/9/17.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
//展开关闭按钮
|
||||
typedef void (^jobBtnAction)(void);
|
||||
//选中
|
||||
typedef void (^jobSelectAction)(NSString *title);
|
||||
|
||||
@interface GiGaUserJobViewCell : UITableViewCell
|
||||
@property (nonatomic,strong) UIButton *upDownBtn;
|
||||
@property (nonatomic,strong) NSArray *jobs;
|
||||
-(void)userSelectjobAction:(jobBtnAction)block;
|
||||
@property (nonatomic,copy) jobBtnAction actionblock;
|
||||
|
||||
-(void)userSelectjob:(jobSelectAction)block;
|
||||
@property (nonatomic,copy) jobSelectAction jobblock;
|
||||
|
||||
-(void)setButtnImage:(BOOL)isUp with:(NSArray *)titles;
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,237 @@
|
||||
//
|
||||
// GiGaUserJobViewCell.m
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/9/17.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import "GiGaUserJobViewCell.h"
|
||||
#import "JobMaskButton.h"
|
||||
#define SPACE_X 8.f //横向间隔
|
||||
#define SPACE_Y 8.f //纵向间隔
|
||||
#define MAR_GAINX 22.f //左右边距
|
||||
#define MARK_H 31.f //高
|
||||
|
||||
@interface GiGaUserJobViewCell()
|
||||
@property (nonatomic,assign) int countY;
|
||||
@property (nonatomic,assign) int countX;
|
||||
@property (nonatomic,strong) NSArray *titles;
|
||||
@property (nonatomic,copy) NSString *selectjob;
|
||||
@end
|
||||
|
||||
@implementation GiGaUserJobViewCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||||
{
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
_countY = 0;
|
||||
_countX = 0;
|
||||
[self creatUI];
|
||||
self.titles = [NSArray new];
|
||||
//self.backgroundColor = [UIColor blueColor];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)creatUI{
|
||||
|
||||
[self addSubview:self.upDownBtn];
|
||||
|
||||
}
|
||||
-(void)updateActionBtnFrame{
|
||||
_upDownBtn.frame = CGRectMake(KMainW - 22 - 55,self.frame.size.height - 31, 55, 31);
|
||||
|
||||
}
|
||||
|
||||
- (UIButton *)upDownBtn{
|
||||
if (!_upDownBtn) {
|
||||
_upDownBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_upDownBtn.frame = CGRectMake(KMainW - 22 - 55, 10, 55, 31);
|
||||
[_upDownBtn addTarget:self action:@selector(upDownBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _upDownBtn;
|
||||
}
|
||||
-(void)upDownBtnAction:(UIButton *)btn{
|
||||
|
||||
if (btn.selected) {
|
||||
NSLog(@"up");
|
||||
}else{
|
||||
NSLog(@"down");
|
||||
}
|
||||
//btn.selected = btn.selected;
|
||||
self.actionblock();
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void)setButtnImage:(BOOL)isUp with:(NSArray *)titles{
|
||||
self.titles = titles;
|
||||
self.selectjob = @"";
|
||||
if (isUp) {
|
||||
[self setUpUPSubViewstitles:titles isUp:isUp];
|
||||
|
||||
}else{
|
||||
[self setUpDownSubviewstitles:titles isUp:isUp];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)setUpUPSubViewstitles:(NSArray *)titles isUp:(BOOL)isUp{
|
||||
//展开状态
|
||||
[_upDownBtn setBackgroundImage:[UIImage imageNamed:@"userjob_up"] forState:UIControlStateNormal];
|
||||
if (titles.count > 0) {
|
||||
for (JobMaskButton *btn in self.subviews) {
|
||||
|
||||
if ([btn isKindOfClass:[JobMaskButton class]]) {
|
||||
[btn removeFromSuperview];
|
||||
}
|
||||
}
|
||||
_countX =0;
|
||||
_countY = 0;
|
||||
CGFloat X = MAR_GAINX;
|
||||
for (int i=0; i<titles.count; i ++) {
|
||||
|
||||
CGFloat width = 0;
|
||||
NSString *title = titles[i];
|
||||
if (title.length == 2) {
|
||||
width = 55;
|
||||
}else if (title.length == 3){
|
||||
width = 68;
|
||||
}else if (title.length == 4){
|
||||
width = 88;
|
||||
}else{
|
||||
//[self makeToast:@"最小两个字"];
|
||||
width = 55;
|
||||
}
|
||||
|
||||
[self creatjob:titles[i] index:i isUp:isUp orinX:X width:width];
|
||||
if (_countX == 0) {
|
||||
X = MAR_GAINX;
|
||||
}else{
|
||||
X = X + width + SPACE_X;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-(void)setUpDownSubviewstitles:(NSArray *)titles isUp:(BOOL)isUp{
|
||||
//收起状态
|
||||
[_upDownBtn setBackgroundImage:[UIImage imageNamed:@"userjob_down"] forState:UIControlStateNormal];
|
||||
if (titles.count > 0) {
|
||||
// [titles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
// NSString *title = obj;
|
||||
// [self creatjob:title index:idx];
|
||||
// }];
|
||||
for (JobMaskButton *btn in self.subviews) {
|
||||
|
||||
if ([btn isKindOfClass:[JobMaskButton class]]) {
|
||||
[btn removeFromSuperview];
|
||||
}
|
||||
}
|
||||
_countX =0;
|
||||
_countY = 0;
|
||||
CGFloat X = MAR_GAINX;
|
||||
for (int i=0; i<titles.count; i ++) {
|
||||
|
||||
CGFloat width = 0;
|
||||
NSString *title = titles[i];
|
||||
if (title.length == 2) {
|
||||
width = 55;
|
||||
}else if (title.length == 3){
|
||||
width = 68;
|
||||
}else if (title.length == 4){
|
||||
width = 88;
|
||||
}else{
|
||||
//[self makeToast:@"最小两个字"];
|
||||
width = 55;
|
||||
}
|
||||
|
||||
[self creatjob:titles[i] index:i isUp:isUp orinX:X width:width];
|
||||
|
||||
if (_countX == 0) {
|
||||
X = MAR_GAINX;
|
||||
}else{
|
||||
X = X + width + SPACE_X;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-(void)creatjob:(NSString *)title index:(int)idx isUp:(BOOL)isUp orinX:(CGFloat)X width:(CGFloat)width{
|
||||
|
||||
|
||||
CGFloat Y = 10 + (MARK_H + SPACE_Y)*_countY;
|
||||
_countX ++;
|
||||
if (!isUp) {
|
||||
|
||||
//关闭状态 只展示一行
|
||||
if ((X + width + SPACE_X) > (KMainW - 55 - 22)){
|
||||
return;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
if (_countY == 0) {
|
||||
|
||||
if ((X + width + SPACE_X) > (KMainW - 55 - 22)){
|
||||
_countY ++;
|
||||
_countX = 0;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
if ((X + width + SPACE_X) > (KMainW - 22 - width)){
|
||||
|
||||
_countY ++;
|
||||
_countX = 0;
|
||||
|
||||
}
|
||||
if (idx == self.titles.count - 1) {
|
||||
[self updateActionBtnFrame];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JobMaskButton *jobBtn = [JobMaskButton buttonWithType:UIButtonTypeCustom];
|
||||
[jobBtn setBackgroundImage:[UIImage imageNamed:@"btn_job"] forState:UIControlStateNormal];
|
||||
jobBtn.jobStr = title;
|
||||
NSAttributedString *attri = [GiGaHelper stringWithText:title textColor:GIGARGB(151, 151, 151, 1) textFont:GIGA_TEXTFONTMEDIUM(13) leterSpace:0];
|
||||
[jobBtn setAttributedTitle:attri forState:UIControlStateNormal];
|
||||
jobBtn.frame = CGRectMake(X,Y, width, MARK_H);
|
||||
[jobBtn addTarget:self action:@selector(jobClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:jobBtn];
|
||||
|
||||
}
|
||||
|
||||
-(void)userSelectjobAction:(jobBtnAction)block{
|
||||
self.actionblock = block;
|
||||
|
||||
}
|
||||
|
||||
-(void)userSelectjob:(jobSelectAction)block{
|
||||
self.jobblock = block;
|
||||
}
|
||||
|
||||
-(void)jobClick:(JobMaskButton *)btn{
|
||||
|
||||
self.jobblock(btn.jobStr);
|
||||
}
|
||||
|
||||
- (void)awakeFromNib {
|
||||
[super awakeFromNib];
|
||||
// Initialization code
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||||
[super setSelected:selected animated:animated];
|
||||
|
||||
// Configure the view for the selected state
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user