iphone - 在我的 UIView 中每 5 分钟调用一次方法

标签 iphone objective-c ios

我想在我的 UIView 代码中调用某个方法,比如每 5 分钟一次 - 我该如何实现?

最佳答案

您可以使用 NSTimer:

将以下内容放入您的 viewDidLoad(其中 300 是秒数):

[NSTimer scheduledTimerWithTimeInterval:300.0f
             target:self
         selector:@selector(updateMethod:)
         userInfo:nil
         repeats:YES];

然后创建您的更新方法:

- (void)updateMethod:(NSTimer *)theTimer {
    // Your code goes here
}

关于iphone - 在我的 UIView 中每 5 分钟调用一次方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6614703/

相关文章:

iphone - GLKView 和 EAGLView 有什么区别?

ios - 使用 MKMapView、核心位置和核心数据

iphone - iOS开发中如何处理自定义事件?

ios - 以编程方式更新 Xcode Assets 目录

ios - Core Data NSInMemoryStoreType 存储会将整个图形存储在内存中,因此会受到系统内存的严重限制吗?

iphone - Android 开发时间与 iPhone 开发时间

iphone - 如何为非常大的 Core Data 数据库创建快速的“按类型搜索”机制?

iphone - 向 View 添加 subview 时,我是 @synthesize 它,还是在 loadView 方法中创建它

ios - 在 VoiceOver 期间将可点击焦点设置在 UIAlertView 的按钮元素上 - UIAccessibility

ios - Redpark 串行电缆在 iPad 4 上不接收数据