我没有在我的项目中使用Size类,并继续使用旧方法进行视图控制器方向.我收到了弃用警告,例如当我使用下面的代码时:
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
...
}
Run Code Online (Sandbox Code Playgroud)
我搜索了很多但找不到合适的方法来修复它.有什么建议 ?
我对 WWDC 2021 上宣布的 Swift 5.5 中新的异步/等待模式感到摸不着头脑,似乎涉及到很多学习内容,但并不像想象的那么容易掌握。我刚刚在 WWDC 视频中看到了这个 for 循环:
for await id in staticImageIDsURL.lines {
let thumbnail = await fetchThumbnail(for: id)
collage.add(thumbnail)
}
let result = await collage.draw()
Run Code Online (Sandbox Code Playgroud)
据我了解,for 循环的每次迭代都会挂起for 循环,直到 fetchThumbnail() 完成运行(可能在不同的线程上)。我的问题:
for循环行中await id的目的是什么?如果我们将 for 循环写成如下而不带 wait 会怎么样?
for id in staticImageIDsURL.lines {
}
Run Code Online (Sandbox Code Playgroud)
上面的for 循环是否始终确保图像以顺序方式添加到拼贴画中,而不是根据提前获取的缩略图以随机顺序添加到拼贴画中?因为在编写代码的经典完成处理程序方式中,确保数组中的顺序需要对代码进行更多逻辑。
UIViews已知是层支持的,但不确定SwiftUI视图。是否有图层的概念SwiftUI,可以将其添加为子图层、动画以及您可以使用的所有内容CALayer?
当使用 XCode 11 beta 构建项目时,我在 iOS 13 beta 6 上看到了一个奇怪的行为。在全屏呈现视图控制器(在 Storyboard 中指定的动画样式“Show”)并关闭后,不会调用呈现视图控制器上的 viewWillAppear。行为有变化吗?
编辑:重复问题中提到的覆盖presentationControllerDidDismiss(_:) 的解决方法对我没有帮助。在关闭通过 Segue 呈现的视图控制器时,它甚至不会被调用。
iPhone 12/12 pro 支持以 10 位格式而不是 8 位格式录制杜比视觉 HDR 视频,但从 iOS 14.1 SDK 中不清楚 AVCaptureVideoDataOutput 是否支持传送 10 位样本缓冲区,这些缓冲区可以使用 AVAssetWriter 附加到视频文件。有没有人想过在SDK中是否可能?
编辑:许多应用程序(例如 Apple 的 Clips 应用程序)已开始支持 Dolby Vision 10 位视频录制。但是我尝试了所有可用的 API,包括 videoHDREnabled,但它不起作用。所以明确的问题是如何使用 AVFoundation API 录制 HDR(杜比视觉)视频?
EDIT2:我能够找出支持 10 位像素缓冲区格式的设备格式(即“x420”,而不是将 420v 或 420f 作为媒体子类型的设备格式)。在 iPhone 12 mini 上,4 种设备格式支持kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange 中的10 位像素缓冲区传送,尽管 AVFoundation 文档说这不是支持的像素格式(引用 - “在 iOS 上,唯一支持的键是 kCVPixelBufferPixelFormatTypeKey。支持的像素格式是 kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange,kCVPixelBufferPixelFormatTypeKey。和 kCVPixelFormatType_32BGRA .”)。下一步是确定是否可以手动选择用于录制的 HDR 格式为 Dolby Vision、HLG 或 HDR10。
avfoundation ios avcapturesession avassetwriter avcapturevideodataoutput
我有一个用于外部屏幕的 UISceneConfiguration,当外部显示器连接到 iOS 设备时会触发该配置。
// MARK: UISceneSession Lifecycle
@available(iOS 13.0, *)
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
switch connectingSceneSession.role {
case .windowApplication:
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
case .windowExternalDisplay:
return UISceneConfiguration(name: "External Screen", sessionRole: connectingSceneSession.role)
default:
fatalError("Unknown Configuration \(connectingSceneSession.role.rawValue)")
}
}
Run Code Online (Sandbox Code Playgroud)
我在链接到外部显示器的新 UIScene 中以这种方式在外部屏幕中显示自定义视图。但现在的问题是,如果我在应用程序流程中也有一个 AVPlayerViewController,它不再显示(播放)到外部屏幕。我想 AVPlayerViewController 可能会为外部显示播放做它自己的配置,但现在我有一个嵌入在外部屏幕上的自定义视图,它无法覆盖它。我需要做什么才能使 AVPlayerViewController 可以按其方式将内容显示到外部屏幕? …
这是一个简单的单视图控制器应用程序:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColor greenColor];
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight;
}
Run Code Online (Sandbox Code Playgroud)
iOS 8中的输出是如此不同.


这与iOS 8与iOS 7的UIWindow界限有什么关系.我如何获得iOS 7的行为?
我看到我的应用程序中的主线程仅在iOS 8上停止了几秒钟(不是以前的iOS版本).
我@synchronised (self)在很多地方使用,也使用RemoteIO设置.我的问题是如何调试主线程阻塞的确切位置并获取其他信息,例如当时正在做什么?
我正在使用Xcode 6所以请告诉我最好的调试方法.
编辑:这是Pause的输出.


我在 iOS 16 上发现了一个奇怪的自动旋转问题,这在其他 iOS 版本中没有出现过。更糟糕的是,如果我将设备连接到 XCode 并进行调试,则不会出现该问题。仅当我通过触摸应用程序图标直接在设备上启动应用程序时才能看到它,这就是我无法识别任何修复的原因。我所做的是在应用程序启动时禁用自动旋转(通过仅返回 .landscape supportedInterfaceOrientations),然后在 0.2 秒后不久,我强制自动旋转到设备的当前界面方向(使用self.setNeedsUpdateOfSupportedInterfaceOrientations)。但是,如果通过触摸应用程序图标直接启动应用程序(而不是从调试器启动),则自动旋转会失败!
这是完整重现该问题的示例代码。运行应用程序时,请确保 iPhone 处于纵向模式。该函数viewWillTransition(to size:, with coordinator:)不会被调用,并且所有子视图不会自动旋转。请建议我一个解决方法!
import UIKit
class ViewController: UIViewController {
public var windowOrientation: UIInterfaceOrientation {
return view.window?.windowScene?.interfaceOrientation ?? .unknown
}
private var disableAutoRotation = true
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
var orientations:UIInterfaceOrientationMask = .landscapeRight
if !self.disableAutoRotation {
orientations = .all
}
return orientations
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.view.backgroundColor = UIColor.systemGreen …Run Code Online (Sandbox Code Playgroud) 当我使用 XCode 14 在 iOS 14 设备上运行代码时,出现此错误。
dyld: Symbol not found: _$s7SwiftUI15GraphicsContextV4fill_4with5styleyAA4PathV_AC7ShadingVAA9FillStyleVtF
Referenced from: ******
Expected in: /System/Library/Frameworks/SwiftUI.framework/SwiftUI
dyld: launch, loading dependent libraries
DYLD_LIBRARY_PATH=/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/usr/lib/libMTLCapture.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
Run Code Online (Sandbox Code Playgroud)
当我在 iOS 15 或 iOS 16 设备上运行相同的代码时,我没有收到任何错误。
我该如何解决这个问题?
编辑:删除 AudioKit 和 AudioKitUI swift 包可以解决该问题。AudioKit 开发人员需要研究这一点。
ios ×7
uikit ×4
ios8 ×3
swift ×3
avfoundation ×2
ios13 ×2
swiftui ×2
async-await ×1
audiokit ×1
autorotate ×1
avplayer ×1
hang ×1
ios16 ×1
ios7.1 ×1
objective-c ×1
swift5 ×1
uiwindow ×1
xcode ×1
xcode14 ×1