全部:
我正在尝试 i) 禁用标题为 Count 的按钮 ii) 将其标题更改为 Busy,并在延迟 delta 秒后 iii) 启用按钮并 iv) 将其标题更改回 Count
这一切都应该发生在 UIButton 操作的代码中。
我可以执行步骤 i)-iii),但步骤 iv) 不起作用:
[sender setEnabled:NO]; // the button is now disabled, clicking on it has no effect
[sender setTitle:@"Busy ... " forState:UIControlStateDisabled];
// wait delay seconds before reenabling the count button
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delta * NSEC_PER_SEC),
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{
[self.countBTN setEnabled:YES];
[self.countBTN setTitle:@"Count" forState:UIControlStateReserved];
});
// after delta seconds, the button is re-enabled, but its title is still "Busy ..."
任何关于为什么这不起作用的见解将不胜感激!