首页 文章
  • 3 votes
     answers
     views

    使用NSTimer iOS目标C暂停/播放音频播放器

    我正在开发一个音乐播放器App . 播放音频时使用播放/暂停按钮和进度条 . 我正在用NSTimer调用一个方法来更新进度条 . 我需要的是暂停进度条并将其恢复到停止的位置 . 我可以使用链接中引用的代码暂停计时器以及进度条:1 . How to pause a NSTimer? 2. How to Pause/Play NSTimer? 但我正在努力恢复它,因为我被迫离开了 . 我还需要根据音频...
  • 0 votes
     answers
     views

    objective c - 不使用返回值调用对象返回方法

    我知道调用一个方法好像它是无效的,即使它有一个返回值(如printf),但是这个怎么样? [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(method) userInfo:nil repeats:NO]; 我可以让它漂浮在那里而不使用它返回的对象吗?这就像调用[NSObject alloc]而不...
  • 1 votes
     answers
     views

    NSTimer Swift难度

    我正在尝试创建一个NSTimer,以便我可以向下移动UIImageView但是NSTImer有困难,先说这个 . var timer = NSTimer.scheduledTimerWithTimeInterval(0.5, target:self(), selector: Selector ("mrockdown"), userInfo: nil, repeats: true...
  • 2 votes
     answers
     views

    如何在我的应用程序进入后台模式时更新位置管理器和计时器?

    我有一个计时器,显示用户锻炼的NSTime . 当我的应用程序进入后台模式时,位置管理器和该计时器停止更新 . 当我的应用处于后台模式时,如何让它们更新? 我有一个名为RunViewController的视图,它有一个启动按钮 . 当用户单击该按钮时,计时器和位置管理器将启动 . 代码是: -(void)startRun{ timeSec = 0; timeMin = 0; ...
  • 0 votes
     answers
     views

    通过我的代码没有错误,主线程上的后台持续时间超过了

    以下代码创建了一个具有主线程超时和被杀死的应用程序的场景 . 我不明白为什么 . 此方法由主线程调用,并且根据堆栈跟踪,此调用不是同步的(它直接从main.m触发) . 然而,为什么需要20秒才能完成?只有在计时器触发后,此事件才会出现吗? [fooObj performSelector:@selector(populate) withObject:nil afterDelay:2]; 崩溃日志...
  • 0 votes
     answers
     views

    NSTimer没有重复

    我正在用Swift创建一个SpriteKit游戏 . 我正在使用NSTimer,调度计时器与目标和选择器的时间间隔 . 虽然重复设置为true,但管道只进出一次 . 这是我的计时器: let timer = NSTimer.scheduledTimerWithTimeInterval(2.0, target: self, selector: "makePipes", userI...
  • 45 votes
     answers
     views

    应用程序在后台时预定的NSTimer?

    当应用程序在后台时,人们如何处理预定的NSTimer? 假设我每小时在我的应用中更新一些内容 . updateTimer = [NSTimer scheduledTimerWithTimeInterval:60.0*60.0 target:self selector:@selector(updateStuff) userInfo:nil repeats:YES]; 在后台时,此计时器显然...
  • 0 votes
     answers
     views

    如何在特定日期触发下载

    在我的iPhone应用程序中,我希望每周一,一个月的每10个工作日,每个月的第3天触发下载等 . 我做了一些研发,发现NSDate,NSDateComponents和NSCalendar类需要用于此场景 . 有人可以提供相同的帮助,因为我是新的日期和时间使用 . 此外,当触发器出现时,如果应用程序未处于运行状态或移动设备已关闭..如何处理这些情况 .
  • 606 votes
     answers
     views

    Swift中的@selector()?

    我正试图在 Swift 中创建 NSTimer 但我遇到了一些麻烦 . NSTimer(timeInterval: 1, target: self, selector: test(), userInfo: nil, repeats: true) test() 是同一类中的函数 . 我在编辑器中收到错误: 找不到接受所提供参数的'init'的重载 当我将 selector: test() 更...
  • 1 votes
     answers
     views

    计时器在swift 4中无法在后台工作,有什么方法可以工作吗?

    我试过下面的代码,但是在后台没有工作,它在地面上运行良好 . 它是从我们将app留在后台的地方开始的 . self.timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(self.updateTimer), userInfo: nil, repeats: true) func updateT...
  • 3 votes
     answers
     views

    后台的NSTimer行为(addTimer:,beginBackgroundTaskWithExpirationHandler :)

    Xcode 6.3.1 ARC Enabled, for iOS 8.3 我需要帮助理解我在应用程序进入后台后在我的应用程序中维护单例共享计时器时遇到的奇怪行为 . 以前我不关心这个NSTimer,因为它使用后台位置服务在后台更新了用户位置 . 但是,我想解决用户在后台或位置更新时拒绝位置更新的情况 . 位置和计时器齐头并进,为我的应用程序 . 我在以下主题和网站帖子中完成了相当多的信息........

热门问题