我有一个带有布尔值的按钮作为切换。每当我更改切换时,我都希望更改标题。但是每当我更改切换时,标题都不会自动更改。有人可以告诉我该怎么做吗?
代码:
@interface OrderController ()
{
std::string currentValue;
bool buttonToggle;
NSString *orderNumber;
}
- (void)viewDidLoad
{
[super viewDidLoad];
buttonToggle = true;
}
- (IBAction)button1:(id)sender
{
if (buttonToggle)
{
[sender setTitle:@"1" forState:UIControlStateNormal];
currentValue += "1";
orderNumber = [NSString stringWithCString:currentValue.c_str() encoding:NSUTF8StringEncoding];
}
else
{
[sender setTitle:@"A" forState:UIControlStateNormal];
orderNumber = [NSString stringWithFormat:@"%@%@", orderNumber, @"A"];
buttonToggle = true;
}
}
- (IBAction)swipeUp:(id)sender
{
buttonToggle = false;
}