【问题标题】:backgroundTimeRemaining returns (35791394 mins)?backgroundTimeRemaining 返回(35791394 分钟)?
【发布时间】:2012-03-01 18:18:10
【问题描述】:

我在我的应用程序中使用 beginBackgroundTaskWithExpirationHandler。我理解后台应用程序完成工作的最长时间是 10 分钟,但是当我打印 backgroundTimeRemaining 的值时得到的是(35791394 分钟)

NSTimeInterval timeLeft = [UIApplication sharedApplication].backgroundTimeRemaining;
    NSLog(@"Background time remaining2222: %.0f seconds (%d mins)", timeLeft, (int)timeLeft / 60);

这是正常的,还是我做错了什么?!

【问题讨论】:

    标签: ios ios5 ios4


    【解决方案1】:

    试试:

    NSLog(@"Background time remaining2222: %.0f seconds (%d mins)", timeLeft, (int)(timeLeft / 60) );
    

    在您的代码中,timeLeft 在除法之前而不是之后更改为 int。

    【讨论】:

      【解决方案2】:

      试试这个:

       NSLog(@"Background time remaining: %f seconds (%d mins)", timeLeft, (int)(timeLeft / 60));
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多