我不知道为什么会遇到这个问题。
详细信息 - 我的应用程序中有一个标签栏控制器。在一个选项卡上,我有一个包含一些按钮的表单。我正在设置这些按钮的标题。现在,当我更改标签并返回相同的标签时,所有按钮标题都显得较暗。
我也附加了屏幕截图。
任何帮助都将不胜感激。
谢谢!
编辑:这是我如何创建按钮的代码 -
-(void)viewWillAppear:(BOOL)animated
{
float yFrame =310.0f;
for(int i =0;i<7;i++){
openPickerButton=[UIButton buttonWithType:UIButtonTypeCustom];
openPickerButton.frame = CGRectMake(29.0, yFrame+10.0, 280.0, 48.0);
openPickerButton.tag=i;
openPickerButton.backgroundColor=[UIColor clearColor];
[openPickerButton setTitle:[formButtonTitle objectAtIndex:openPickerButton.tag] forState:UIControlStateNormal];
openPickerButton.titleLabel.font=[UIFont fontWithName:@"Helvetica" size:16];
[openPickerButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
openPickerButton.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
openPickerButton.showsTouchWhenHighlighted = YES;
[openPickerButton addTarget:self action:@selector(PickChoreButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[setPreferencesFormScrollView addSubview:openPickerButton];
yFrame+=60.0f;
}
}
答案 0 :(得分:1)
而不是在viewWillAppear方法中创建按钮,而不是在viewDidLoad方法中创建按钮
答案 1 :(得分:1)
在viewDidLoad中你的对象被调用一次。(一旦视图加载。 停止) 在viewWillAppear中,每次出现视图时都会调用它们。
- (void)viewDidLoad
{
[super viewDidLoad];
float yFrame =310.0f;
for(int i =0;i<7;i++){
openPickerButton=[UIButton buttonWithType:UIButtonTypeCustom];
openPickerButton.frame = CGRectMake(29.0, yFrame+10.0, 280.0, 48.0);
openPickerButton.tag=i;
openPickerButton.backgroundColor=[UIColor clearColor];
[openPickerButton setTitle:[formButtonTitle objectAtIndex:openPickerButton.tag] forState:UIControlStateNormal];
openPickerButton.titleLabel.font=[UIFont fontWithName:@"Helvetica" size:16];
[openPickerButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
openPickerButton.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
openPickerButton.showsTouchWhenHighlighted = YES;
[openPickerButton addTarget:self action:@selector(PickChoreButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[setPreferencesFormScrollView addSubview:openPickerButton];
yFrame+=60.0f;
}
}