如果用户点击主页按钮终止应用程序,如何保存正在进行的视频捕获

发布于 2024-09-24 19:31:38 字数 300 浏览 0 评论 0 原文

我正在使用 UIImagePickerController 来捕获视频。 我已将代理设置为在视频捕获停止时保存捕获的视频。 当程序根据用户操作调用 stopVideoCapture 时,委托会被调用。

如果在进行视频捕获时用户按下主页按钮终止应用程序,我希望也会发生相同的操作。

我尝试在 applicationWillTerminate 中添加调用 stopVideoCapture,但由于某种原因,未调用保存视频的委托操作。 imagePickerController 委托是一个单独的视图控制器,而不是 UIApplicationDelegate。

I am using UIImagePickerController to capture video.
I have set the delegate to save the captured video when video capture is stopped.
The delegate does get called when stopVideoCapture is called by the program based on user action.

I would like the same actions to also happen if while video capture is in progress the user presses the home button to terminate the app.

I tried adding call stopVideoCapture in applicationWillTerminate but for some reason the delegate action to save the video is not being called. The imagePickerController delegate is a separate view controller and not the UIApplicationDelegate.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

放低过去 2024-10-01 19:31:38

从 iOS 4.0 开始,当用户按下主页按钮时,将不会调用 applicationWillTerminate。相反,请参阅 applicationDidEnterBackground: (或者让您的视图控制器监听 UIApplicationDidEnterBackgroundNotification 通知)。尝试使用 beginBackgroundTaskWithExpirationHandler: 设置后台任务。

As of iOS 4.0, applicationWillTerminate will not be called when the user presses the home button. Instead, see applicationDidEnterBackground: (or have your view controller listen to the UIApplicationDidEnterBackgroundNotification notification). Try setting up a background task with beginBackgroundTaskWithExpirationHandler:.

稚然 2024-10-01 19:31:38

您应该在退出前检查 iOS 4.0 对短时后台任务的支持,检查 beginBackgroundTaskWithExpirationHandler。

以下是 Apple 文档的链接。

You should check iOS 4.0 support for short-time background tasks before exit, check beginBackgroundTaskWithExpirationHandler.

Here's link to Apple documentation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文