【问题标题】:How to make button disable while moving to other view also?如何在移动到其他视图时也禁用按钮?
【发布时间】:2016-05-30 05:46:26
【问题描述】:

我想在特定时间禁用按钮:

我的问题

在时间到期之前,如果我移动到其他视图并返回相同的视图,按钮就会启用。

我的问题

如何在移动到其他视图时也禁用按钮?

我应用这段代码来实现我想要的..

UIBackgroundTaskIdentifier task =0;
UIApplication  *app = [UIApplication sharedApplication];
task = [app beginBackgroundTaskWithExpirationHandler:^{[app endBackgroundTask:task]; }];NSTimer *timer;
timer = [NSTimer scheduledTimerWithTimeInterval:(0.25 * 60) target:self
             selector:@selector(timerCountDown)userInfo:nil repeats:NO];

提前致谢..

【问题讨论】:

    标签: ios iphone background uibutton nstimer


    【解决方案1】:

    为了快速使用此代码:

    var button = UIButton()
    button.enabled = false 
    

    目标-C

    [yourButton setEnabled:NO];
    

    【讨论】:

      【解决方案2】:

      您可以借助必须维护的布尔值禁用和启用。

      使用 Swift 语言:-

      //Create any Button property of Initialize here 
      let button = UIButton()
      
      //Then here you can disable button events.
      button.userInteractionEnabled = false
      
      //Then here you can enable button events.
      button.userInteractionEnabled = true
      

      我希望这对你有帮助。

      【讨论】:

        猜你喜欢
        • 2012-06-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-06-20
        • 1970-01-01
        • 2013-08-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多