标签: ios16

如何在 iOS 16.0 的 Swift Charts 中的折线图上配置轴并设置显式轴起点和终点

在此代码中,我声明一个图表,其 x 比例域位于两个双精度数之间:

Chart(points, id: \.self) { point in
    LineMark(
        x: .value("time/s", point.timestamp),
        y: .value("potential/mV", point.potential)
    )
    .foregroundStyle(by: .value("Electrode", point.electrode.symbol))
}
.chartXScale(domain: timeWindow)
// ...
Run Code Online (Sandbox Code Playgroud)

其中timeWindow声明如下:

var timeWindow: ClosedRange<Double> {
    doc.contents.time(at: window.lowerBound)...doc.contents.time(at: window.upperBound)
}
Run Code Online (Sandbox Code Playgroud)

time定义为:

func time(at index: Int) -> Double {
    return Double(index) * (1 / sampleRate)
}
Run Code Online (Sandbox Code Playgroud)

然而,生成的图表 x 轴在我提供的下限和上限处没有起点和终点ClosedRange<Double>,而是在图的左侧和右侧有一段神秘空间:

LineMark 图右侧图表中的空白区域。

如何使图表遵循我提供的域(边界也显示在底部工具栏工具栏项目组的文本视图中,使用代码Text("\(timeWindow.lowerBound.format()) s to \(timeWindow.upperBound.format()) s"))?如何让 y 轴呈现在图表左侧?

swift swiftui ios16

4
推荐指数
1
解决办法
6220
查看次数

Xcode 13.2.1 iOS 16.0 设备支持文件不起作用

今天将我的 iPhone 更新到 iOS 16.0,从 GitHub 上的已知存储库(即https://github.com/iGhibli/iOS-DeviceSupport )安装了 16.0 的设备支持文件,然后尝试从 Xcode 13.2.1 进行构建,但仍然如此不支持 iOS 16.0。以前,这个技巧适用于 15.5 和 15.6,但现在不适用于 16.0。16.0的文件有问题吗?他们看起来大约3个月大。有没有人见过这个问题并找到解决方案?谢谢!

xcode ios16

3
推荐指数
1
解决办法
5105
查看次数

VNDetectBarcodesRequest 在 iOS16 上不起作用

我在 iOS 16 上遇到问题。VNDetectBarcodesRequest我的代码在 iOS 15 上按预期工作,但在 iOS 16 上它在图像中找不到任何条形码。

我已将代码分离到游乐场,并且在这里遇到了同样的问题。在 Xcode 13.4.1 的 Playground 上运行下面的代码,得到结果:

“Google 链接:可选(“https://www.google.com”)”

在 Xcode 14 上运行相同的代码,我得到了nil结果。在带有 Xcode 14 的 iOS15 模拟器中运行此命令会给出积极的结果,仅在 iOS16 和 Playground 上它不会读取 QR 码。

除此之外,也不会抛出任何异常。

有没有人经历过同样的事情并设法解决这个问题?

这是我的游乐场代码:

import UIKit
import Vision

extension UIImage {
    func qrCodeLink(completion: @escaping (String?) -> Void) {
        guard let ciImage = CIImage(image: self) else {
            completion(nil)
            return
        }
        let imageRequestHandler = VNImageRequestHandler(ciImage: ciImage,
                                                        orientation: .up,
                                                        options: [:])       
        let request = VNDetectBarcodesRequest { (request,error) …
Run Code Online (Sandbox Code Playgroud)

vision swift ios16 xcode14

3
推荐指数
2
解决办法
1509
查看次数

CSS hack也支持IOS16

这个 CSS hack 曾经适用于 iOS 15.6,但在 iOS 16 中不起作用。

@media not all and (min-resolution:.001dpcm) {
    @supports (-webkit-appearance:none) {}
}
Run Code Online (Sandbox Code Playgroud)

有没有针对 Safari 16 的新黑客?

css media-queries ios16

3
推荐指数
1
解决办法
2842
查看次数

iOS16.1 Mapkit [VKDefault] 超出金属缓冲区阈值 50000

因此对于我们的地图,我们使用 MapKit。我们使用 MKPolygons 在地图上方叠加一个图层。此功能自 iOS15 起一直有效,但自 16.1 起,我们收到以下错误,并且应用程序冻结(不会崩溃)。

  • [VKDefault] Exceeded Metal Buffer threshold of 50000 with a count of 50892 resources, pruning resources now (Time since last prune:6.497636): Assertion with expression - false : Failed in file - /Library/Caches/com.apple.xbs/Sources/VectorKit/src/MDMapEngine.mm line - 1363

  • Metal API Validation Enabled [PipelineLibrary] Mapping the pipeline data cache failed, errno 22

另一个有趣的日志如下

  • [IconManager] No config pack found for key SPR London Landmarks

知道如何手动清除金属缓存吗?

mapkit ios swift metal ios16

3
推荐指数
1
解决办法
1113
查看次数

Xcode14 beta(iOS 16)、SwiftUI、_clockHandRotationEffect 不再存在

为了在主屏幕小部件上实现时钟动画。我用

_clockHandRotationEffect(.custom(cycleTime), in:.current, anchor: .center)
Run Code Online (Sandbox Code Playgroud)

但在Xcode14上,它不再存在了。 在此输入图像描述

有替代品吗?

home-screen-widget swiftui ios16 xcode14

2
推荐指数
1
解决办法
1319
查看次数

集成万能钥匙 signCount 0

我正在尝试在我的应用程序中实现密钥。我想知道 ASAuthorizationPublicKeyCredentialAssertion.rawAuthenticatorData 是否支持signCount。看来值总是0。谢谢!

password-less webauthn ios16 passkey

2
推荐指数
1
解决办法
395
查看次数

将 UIEditMenuInteraction 与 UITextView 结合使用

我们如何使用 UIEditMenuInteraction 和 UITextView 来自定义菜单并添加更多按钮?

在 iOS 16 之前我使用的是:

UIMenuController.shared.menuItems = [menuItem1, menuItem2, menuItem3]
Run Code Online (Sandbox Code Playgroud)

uitextview swift ios16

2
推荐指数
1
解决办法
3608
查看次数

RegionCode 将在 iOS 16 中弃用

从 iOS 16 开始,regionCode尝试regionCode从当前区域设置访问时不再适用。喜欢这个代码

let locale = Locale.current
locale.regionCode
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

xcode ios swift ios16

2
推荐指数
1
解决办法
1911
查看次数

编译错误“实例方法‘someMethod’中函数类型的可发送性与协议‘SomeProtocol’中的要求不匹配”iOS 16 Swift 5.7

更新到 Xcode 14、iOS 16、Swift 5.7 后,编译项目时我得到:

Sendability of function types in instance method 'addObserver(forName:object:queue:using:)' does not match requirement in protocol 'NotificationCenterProtocol'
Run Code Online (Sandbox Code Playgroud)

ios swift ios16 swift5.7

2
推荐指数
1
解决办法
751
查看次数

SiwiftUI:UITextView 正在切换到 TextKit 1

我收到日志消息UITextView 正在切换到 TextKit 1 兼容模式,因为它的 textStorage 包含与NSAttributedString使用的TextKit 2 不兼容的属性。documentType: NSAttributedString.DocumentType.html

例子:

func makeUIView(context: Context) -> UITextView {
    let textView = UITextView()
    return textView
}

func updateUIView(_ uiView: UITextView, context _: Context) {
    var currentText: NSAttributedString?
    let htmlString = "<html><body><h1>Example</h1></body></html>"
    
    guard let encodedData = htmlString.data(using: .utf8) else {
        fatalError("Could not encode HTML data")
    }
    
    do {
        currentText = try NSAttributedString(data: encodedData,
                                             options: [
                                                .documentType: NSAttributedString.DocumentType.html,
                                                .characterEncoding: String.Encoding.utf8.rawValue
                                             ],
                                             documentAttributes: nil)
    } catch let error as NSError {
        fatalError(error.localizedDescription)
    } …
Run Code Online (Sandbox Code Playgroud)

uitextview textkit swiftui ios16

2
推荐指数
1
解决办法
1980
查看次数

我们如何控制 SwiftUI 表单中的自动分隔线?

我很好奇,有没有一种方法可以控制(或理解) swiftui 在项目之间放置的自动分隔线?

下面是一些显示奇怪行为的代码(在 iOS 模拟器上):

struct FormSeparator: View {
    @State private var passwd = ""
    var body: some View {
        Form {
            ZStack(alignment: .trailing) {
                TextField("password", text:$passwd)
                Text("8 chars min")
                    .font(.caption)
                    .foregroundColor(.secondary)
            }
            TextField("confirm", text:$passwd)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

结果如下:

奇怪的分隔线的例子

Text这似乎与我堆叠在密码字段顶部的内容有关。如果我将其文本更改为,Image(systemName: "lock")那么一切都会按您的预期进行:

普通分隔线示例

请注意,我什至不明白为什么在这种情况下它没有一直延伸到整个表单。大概这是故意的,有人见过关于这种情况的官方信息吗?我们知道如何控制它吗?

swift swiftui ios16

2
推荐指数
1
解决办法
340
查看次数

SwiftUI NavigationStack NavigationLink 相同值,多个目的地

我有一个这样的模型...

struct User: Codable {
    let followersCount: Int
    let followingCount: Int
}
Run Code Online (Sandbox Code Playgroud)

使用 NavigationStack 我希望能够使用基于 Value 的 NavigationLink

 NavigationLink(value: user.followersCount) {
    Text("Followers")
}

NavigationLink(value: user.followingCount) {
    Text("Following")
}
.navigationDestination(for: Int.self) { _ in
    FollowersView()
}

.navigationDestination(for: Int.self) { _ in
    FollowingView()
}
Run Code Online (Sandbox Code Playgroud)

因为这两个值都是 Int。有没有办法区分两者?

swiftui swiftui-navigationlink ios16 swiftui-navigationstack

2
推荐指数
1
解决办法
861
查看次数