1
This commit is contained in:
@@ -32,11 +32,11 @@
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = UIColor.clearColor;
|
||||
// 默认三项
|
||||
// 默认三项(使用多语言文案)
|
||||
_items = @[
|
||||
@{ @"id": @"1", @"name": @"Male" },
|
||||
@{ @"id": @"2", @"name": @"Female" },
|
||||
@{ @"id": @"3", @"name": @"The Third Gender" },
|
||||
@{ @"id": @"1", @"name": KBLocalized(@"Male") },
|
||||
@{ @"id": @"2", @"name": KBLocalized(@"Female") },
|
||||
@{ @"id": @"3", @"name": KBLocalized(@"The Third Gender") },
|
||||
];
|
||||
[self buildUI];
|
||||
[self makeConstraints];
|
||||
|
||||
@@ -49,6 +49,9 @@
|
||||
self.kb_navView.backgroundColor = [UIColor clearColor];
|
||||
self.view.backgroundColor = [UIColor colorWithHex:0xF8F8F8];
|
||||
|
||||
// 根据用户模型的 gender 显示当前性别,支持多语言
|
||||
NSString *genderText = [self kb_genderDisplayText];
|
||||
|
||||
// 构造数据
|
||||
// self.items = @[
|
||||
// @{ @"title": KBLocalized(@"Nickname"), @"value": @"", @"arrow": @YES, @"copy": @NO },
|
||||
@@ -57,7 +60,7 @@
|
||||
// ];
|
||||
self.items = @[
|
||||
@{ @"title": KBLocalized(@"Nickname"), @"value": self.userModel.nickName, @"arrow": @YES, @"copy": @NO },
|
||||
@{ @"title": KBLocalized(@"Gender"), @"value": @"Choose", @"arrow": @YES, @"copy": @NO },
|
||||
@{ @"title": KBLocalized(@"Gender"), @"value": genderText, @"arrow": @YES, @"copy": @NO },
|
||||
@{ @"title": KBLocalized(@"User ID"), @"value": self.userModel.userId, @"arrow": @NO, @"copy": @YES },
|
||||
];
|
||||
|
||||
@@ -91,6 +94,23 @@
|
||||
self.modifyLabel.text = userModel.nickName;
|
||||
}
|
||||
|
||||
/// 根据 userModel.gender 生成展示用的性别文案(带多语言)
|
||||
- (NSString *)kb_genderDisplayText {
|
||||
if (!self.userModel) {
|
||||
return KBLocalized(@"Choose");
|
||||
}
|
||||
switch (self.userModel.gender) {
|
||||
case UserSexMan:
|
||||
return KBLocalized(@"Male");
|
||||
case UserSexWeman:
|
||||
return KBLocalized(@"Female");
|
||||
case UserSexTwoSex:
|
||||
return KBLocalized(@"The Third Gender");
|
||||
default:
|
||||
return KBLocalized(@"Choose");
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UITableView
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; }
|
||||
@@ -154,8 +174,12 @@
|
||||
[pop pop];
|
||||
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.15 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [content focusInput]; });
|
||||
} else if (indexPath.row == 1) {
|
||||
// 性别选择 -> 弹窗
|
||||
NSArray *genders = @[ @{@"id":@"1",@"name":@"Male"}, @{@"id":@"2",@"name":@"Female"}, @{@"id":@"3",@"name":@"The Third Gender"} ];
|
||||
// 性别选择 -> 弹窗(性别文案支持多语言)
|
||||
NSArray *genders = @[
|
||||
@{@"id":@"1",@"name":KBLocalized(@"Male")},
|
||||
@{@"id":@"2",@"name":KBLocalized(@"Female")},
|
||||
@{@"id":@"3",@"name":KBLocalized(@"The Third Gender")},
|
||||
];
|
||||
CGFloat width = KB_SCREEN_WIDTH;
|
||||
KBGenderPickerPopView *content = [[KBGenderPickerPopView alloc] initWithFrame:CGRectMake(0, 0, width, 300)];
|
||||
content.items = genders;
|
||||
|
||||
Reference in New Issue
Block a user