我正在使用 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.
发布评论
评论(2)
从 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, seeapplicationDidEnterBackground:
(or have your view controller listen to theUIApplicationDidEnterBackgroundNotification
notification). Try setting up a background task withbeginBackgroundTaskWithExpirationHandler:
.您应该在退出前检查 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.