用户触摸 UIButton 次数过多 iPhone
如果用户不耐烦并在加载下一个视图之前触摸此按钮,我会遇到嵌套视图问题,为什么这不起作用?我以为将按钮 BOOL 启用为 no 可以修复它,但事实并非如此。
-(IBAction)start:(id)sender
{
startButton.enabled = NO;
[activity startAnimating];
[locationManager stopUpdatingLocation];
ViewController *view = [[ViewController alloc]init];
NSManagedObjectContext *context = [self managedObjectContext];
view.managedObjectContext = context;
[self.navigationController pushViewController:view animated:YES];
}
If the user gets impatient and touches this button before the next view can load, I get nested view issues, why isn't this working? I assumed that turning the button BOOL enabled to no would fix it, but it doesn't.
-(IBAction)start:(id)sender
{
startButton.enabled = NO;
[activity startAnimating];
[locationManager stopUpdatingLocation];
ViewController *view = [[ViewController alloc]init];
NSManagedObjectContext *context = [self managedObjectContext];
view.managedObjectContext = context;
[self.navigationController pushViewController:view animated:YES];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该 OP 代码应该可以工作。确保 startButton 是正确的按钮并已在 IB 中连接。
如果该操作是由您要禁用的按钮引起的,则
self.enabled = NO;
更直接。That OP code should work. Ensure startButton is the correct button and connected in IB.
If the action is caused by the button you want to disable then
self.enabled = NO;
is more direct.将整个事情放在 if 语句中。
并在需要时将变量 = 设置为 TRUE 或 FALSE。
Have the entire thing inside an if statement.
And set your variable = to TRUE or FALSE whenever you need to.