火炬在背景中 [英] Torch in background

查看:102
本文介绍了火炬在背景中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当应用程序在后台运行时,是否可以进行手电筒照明?

Is this possible to make torch lighting when app is in background?

我要这样做是为了打开它:

This is what I do to turn it on:

AVCaptureSession *session = [AVCaptureSession new];
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

[session beginConfiguration];
[device lockForConfiguration:nil];

device.torchMode = AVCaptureTorchModeOn;

[device unlockForConfiguration];
[session commitConfiguration];

[session startRunning];

但是当应用程序转到后台时,割炬会自动关闭。而且我无法从后台找回光亮。

But when app goes to background torch is automatically turned off. And I cannot get back the light from background.

推荐答案

在后台运行时,您的应用程序无法工作或从系统。唯一允许的情况是:

When in background your application doesn't work or get any messages from the system. The only cases when this is allowed are:

navigation application
audio player
Internet telephony

除非您正在设计以上任何一项,否则您无法使用任何内容闪烁用户。如果您只想通知用户某事,则可以创建一个通知程序,即使您的应用程序处于后台或完全关闭状态,该通知程序也会在用户窗口中弹出一条消息。用户可以单击该消息,然后他将返回您的应用程序。除非监狱越狱,否则答案是否定的

Unless you are designing any of the above you can not flash the user with anything. If you only want to notify the user about something, you can create a notifier that will pop a message in the users window even if your application is in the background or entirely off. the user can click the message and then he will be back to your application.Exact answer is no unless Jailbroken

这篇关于火炬在背景中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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