如何在 iPhone 应用程序中的特定时间每天调用一个方法? [英] How to invoke a method daily at a specific time in iPhone application?

查看:29
本文介绍了如何在 iPhone 应用程序中的特定时间每天调用一个方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想每天在特定时间在我的 iPhone 应用程序中调用一个方法.我怎样才能做到这一点?

I want to invoke a method daily at a specific time in my iPhone application. How can I achieve this?

推荐答案

使用 iPhone SDK 和封闭的应用程序,您无能为力.您可以让它在特定时间发送本地推送通知,但在用户手动打开您的应用之前不会执行您的代码.

There's not a whole lot you can do with the iPhone SDK and a closed app. You can have it send local push notifications at specific times, but that won't execute your code until the user manually opens your app.

查看最近提出的这个相关问题:是否可以让我关闭的应用程序在 iOS 中运行代码?

See this related question recently asked: Is it possible to have my closed app run code in iOS?

我见过应用(例如闹钟应用等)所做的一件事是让应用保持打开状态,让手机进入睡眠状态,然后它仍会在您需要时执行代码.但这只有在用户不点击主页按钮时才有效.

One thing I've seen apps do (like alarm clock apps, etc) is have you leave your app open and just let the phone fall asleep and then it will still execute code when you want it to. But that only works as long as the user doesn't hit the home button.

这篇关于如何在 iPhone 应用程序中的特定时间每天调用一个方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆