首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >模拟器支持后台模式吗?

模拟器支持后台模式吗?
EN

Stack Overflow用户
提问于 2013-09-02 08:54:49
回答 4查看 2.2K关注 0票数 1

如何启动背景语音处理。模拟器是否支持iOS中的背景模式。

这是我的代码启动背景process.But,它不是working.when,我按下主页按钮录音停止。

代码语言:javascript
复制
-(void)applicationDidEnterBackground:(UIApplication *)application
{
    if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]) { //Check if our iOS version supports multitasking I.E iOS 4
        if ([[UIDevice currentDevice] isMultitaskingSupported]) { //Check if device supports multitasking
            UIApplication *application = [UIApplication sharedApplication]; //Get the shared application instance
            __block UIBackgroundTaskIdentifier background_task; //Create a task object
            background_task = [application beginBackgroundTaskWithExpirationHandler: ^ {
                [application endBackgroundTask: background_task]; //Tell the system that we are done with the tasks
                background_task = UIBackgroundTaskInvalid; //Set the task to be invalid
                //System will be shutting down the app at any point in time now
            }];
            //Background tasks require you to use asyncrous tasks
            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                //Perform your tasks that your application requires
                NSLog(@"\n\nRunning in the background!\n\n");
                NSString *pollingTimer2 = [NSTimer scheduledTimerWithTimeInterval:1
                                                                           target:self
                                                                         selector:@selector(recordPauseTapped:)
                                                                         userInfo:nil
                                                                          repeats:YES];
                [application endBackgroundTask: background_task]; //End the task so the system knows that you are done with what you need to perform
                background_task = UIBackgroundTaskInvalid; //Invalidate the background_task
            });
        }
    }

}
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2013-09-19 07:17:42

若要检查设备是否支持多任务处理,请使用以下代码:

代码语言:javascript
复制
if ([[UIDevice currentDevice] isMultitaskingSupported])

虽然模拟器有一些硬件限制,包括:

-Accelerometer

-Gyroscope

-Camera

-Proximity传感器

-Microphone输入

要在设备上测试应用程序,您必须是iOS开发人员程序的成员。要了解有关注册iOS开发人员程序的更多信息,请参见应用程序发行指南中的“注册Apple程序并访问其工具”。您不能在模拟器上测试所有这些特性。

票数 1
EN

Stack Overflow用户

发布于 2013-09-02 09:06:20

不,它不支持背景模式。

票数 1
EN

Stack Overflow用户

发布于 2013-09-02 09:12:11

模拟器支持后台模式,但是您的条件(如下面所示)将在模拟器上失败&因此出现了问题。

如果([UIDevice currentDevice isMultitaskingSupported])

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18569161

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档