我有一个视频分析应用程序,我正在尝试使其与visionOS 兼容。由于不允许使用相机而崩溃;Apple 只允许从照片导入视频。
因此,我需要在启动时检查设备是否运行visionOS来显示照片选择器而不是相机视图,类似于我现在使用的检查我是否在macCatalyst或iOS上:
#if targetEnvironment(macCatalyst)
print("We are in macOS Catalyst")
#else
print("We are in iOS")
#endif
Run Code Online (Sandbox Code Playgroud)
提前致谢。
我正在制作一个应用程序,以设备最大帧速率(即 iPhone 5s 中的 120fps,6 和 6s 中的 240fps)录制视频。我已经成功配置了AVCaptureDevice设置maxFrameRateDuration,我打印到日志currentDevice.activeFormat.videoSupportedFrameRateRanges,一切都很好。
但是当我尝试保存视频时,它确实保存了它,但以正常帧速率,而不是 120 或 240fps。
请问有人可以帮我吗?任何帮助将非常感激。
提前致谢。
PS:这是迄今为止我的完整代码
import UIKit
import AVFoundation
import AVKit
import AssetsLibrary
class ViewController: UIViewController, AVCaptureFileOutputRecordingDelegate {
@IBOutlet weak var cameraButton:UIButton!
let captureSession = AVCaptureSession()
var currentDevice:AVCaptureDevice?
var videoFileOutput:AVCaptureMovieFileOutput?
var cameraPreviewLayer:AVCaptureVideoPreviewLayer?
var outputPath: String = ""
var backgroundRecordId: UIBackgroundTaskIdentifier = UIBackgroundTaskInvalid
var isRecording = false
override func viewDidLoad() {
super.viewDidLoad()
// Preset the session for taking photo in full resolution
captureSession.sessionPreset = …Run Code Online (Sandbox Code Playgroud) 我知道有人问过类似的问题,但我找不到任何可以解决我的问题的东西。
\n就我而言,我开发了一个 iOS 应用程序 (Xcode 13.4),用于导入和解析我使用 .csv 文件选择的 CSV 文件中的数据UIDocumentPickerViewController。在模拟器上一切正常,但是当我在 iPhone 上运行该应用程序时,当我选择一个文件并尝试解析它时,我的应用程序崩溃并出现错误The file "test.csv" couldn\xe2\x80\x99t be opened because you don\xe2\x80\x99t have permission to view it。我已在我的文件中添加了与文档访问相关的所有权限,Info.plist如下所示:
<key>NSFileProviderDomainUsageDescription</key>\n <string>Description</string>\n <key>UISupportsDocumentBrowser</key>\n <true/>\n <key>NSDesktopFolderUsageDescription</key>\n <string></string>\n <key>NSDownloadsFolderUsageDescription</key>\n <string></string>\n <key>NSFileProviderPresenceUsageDescription</key>\n <string></string>\n <key>NSAppleMusicUsageDescription</key>\n <string></string>\n <key>UIFileSharingEnabled</key>\n <true/>\n <key>NSDocumentsFolderUsageDescription</key>\n <string>Description</string>\n <key>LSSupportsOpeningDocumentsInPlace</key>\n <true/>\nRun Code Online (Sandbox Code Playgroud)\n但没有任何作用。我错过了什么吗?提前致谢!
\n