大家好!
基本上,我正在尝试从我的 UIButton 中创建一个简单的切换。使用下面的代码,我可以单击该按钮,但只有一小会儿我会看到@"Expense"作为标题。这可能是一个非常简单的错误。感谢您的帮助!
- (IBAction)typeChanger {
if ([typeButton.titleLabel.text isEqual:@"Income"]) {
typeButton.titleLabel.text = @"Expense";
}else if ([typeButton.titleLabel.text isEqual:@"Expense"]) {
typeButton.titleLabel.text = @"Income";
}
}
提前致谢!
最佳答案
这样做,
- (IBAction)typeChanger {
if ([typeButton.titleLabel.text isEqual:@"Income"]) {
[typeButton setTitle:@"Expense" forState:UIControlStateNormal];
}else if ([typeButton.titleLabel.text isEqual:@"Expense"]) {
[typeButton setTitle:@"Income" forState:UIControlStateNormal];
}
}
关于iphone - 从不工作的 UIButton 创建切换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15081352/