Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cancelButtonText 和 confirmButtonText 设置无效 #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

YQqiang
Copy link

@YQqiang YQqiang commented Aug 15, 2019

分析:
设置 取消 确定按钮文案的方法有两处:

  1. setLanguage: 方法中
- (void)setLanguage:(NSString *)language {
    _language = language;
    
    NSString *cancelButtonText = [NSBundle pg_localizedStringForKey:@"cancelButtonText" language:self.language];
    [self.cancelButton setTitle:cancelButtonText forState:UIControlStateNormal];
    
    NSString *confirmButtonText = [NSBundle pg_localizedStringForKey:@"confirmButtonText" language:self.language];
    [self.confirmButton setTitle:confirmButtonText forState:UIControlStateNormal];
}
  1. setupButton 方法中
- (void)setupButton {
    [self.cancelButton setTitle:self.cancelButtonText forState:UIControlStateNormal];
    [self.confirmButton setTitle:self.confirmButtonText forState:UIControlStateNormal];
}

setupButton的调用时机为: PGDatePickManagerHeaderViewlayoutSubviews时;
setLanguage:的调用时机为:PGDatePickManagerviewDidLayoutSubviews时;

iOS 9.3.2系统下的表现行为是:先调用PGDatePickManagerHeaderViewlayoutSubviews,然后调用 PGDatePickManagerviewDidLayoutSubviews

表现的结果是:cancelButtonTextconfirmButtonText 无效

修复:
setLanguage: 中检查cancelButtonText,confirmButtonText 是否有值

- (void)setLanguage:(NSString *)language {
    _language = language;
    if (!_cancelButtonText || _cancelButtonText.length <= 0) {
        NSString *cancelButtonText = [NSBundle pg_localizedStringForKey:@"cancelButtonText" language:self.language];
        [self.cancelButton setTitle:cancelButtonText forState:UIControlStateNormal];
    }
    
    if (!_confirmButtonText || _confirmButtonText.length <= 0) {
        NSString *confirmButtonText = [NSBundle pg_localizedStringForKey:@"confirmButtonText" language:self.language];
        [self.confirmButton setTitle:confirmButtonText forState:UIControlStateNormal];
    }
}

…t 设置无效

- (void)setLanguage:(NSString *)language {} 中检查cancelButtonText,confirmButtonText 是否有值

BREAKING CHANGE: PGDatePickManagerHeaderView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant