我有一个关于 IOS 16 中新的 NavigationStack 的问题。我在 ContentView 中设置 navigationTitle 时遇到问题,我设置了 navigationTitle 但它对所有选项卡都是相同的。我可以以某种方式设置它,以便我可以为每个不同的选项卡编辑它吗?使用标签?非常感谢
struct ContentView: View {
@State var selection = 1
var body: some View {
NavigationStack {
TabView(selection: $selection) {
LaunchView()
.badge(2)
.tabItem {
Label("Received", systemImage: "tray.and.arrow.down.fill")
}
.tag(1)
DeView()
.tabItem {
Label("Sent", systemImage: "tray.and.arrow.up.fill")
}
.tag(2)
DeView()
.tabItem {
Label("Sent", systemImage: "tray.and.arrow.up.fill")
}
.tag(3)
}
.navigationTitle("test")
}
}
Run Code Online (Sandbox Code Playgroud)
}
使用新的 SwiftUI Charts 框架,我们可以制作比可见屏幕更大的图表,并将其放入 ScrollView 中以使其可滚动。像这样的东西:
var body : some View {
GeometryReader { proxy in
ScrollView(.horizontal, showsIndicators: false) {
Chart {
ForEach(data) { entry in
// ...
}
}
.frame(width: proxy.size.width * 2)
}
}
}
Run Code Online (Sandbox Code Playgroud)
有谁知道是否可以以编程方式移动滚动以显示图表的特定区域?
我尝试过使用ScrollViewReader,在 x 轴标签处设置 ID,并尝试使用该scrollTo函数导航到任何这些位置,但没有成功:
Chart {
/// ...
}
.chartXAxis {
AxisMarks(values: .stride(by: .day)) { value in
if let date : Date = value.as(Date.self) {
Text(date, style: .date)
.font(.footnote)
}
}
}
Run Code Online (Sandbox Code Playgroud) 我可以在 SwiftUI 中显示具有自定义高度和棘爪的工作表,如下所示。
.sheet(isPresented: $showSheet) {
MySheet()
presentationDetents([.height(500), .large])
}
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以测量我的视图的准确高度MySheet并将其传递给presentationDetents没有固定值的?我问这个问题是因为根据用户的辅助功能设置,视图的高度可能会发生变化。
我正在尝试监听布尔值的变化,并在听到成功后更改视图,但是会产生黄色三角形。我还没有设法查明问题,但它似乎与它正在转换的视图没有任何关系,因为即使更改后错误仍然存在。
我的代码如下
import SwiftUI
struct ConversationsView: View {
@State var isShowingNewMessageView = false
@State var showChat = false
@State var root = [Root]()
var body: some View {
NavigationStack(path: $root) {
ZStack(alignment: .bottomTrailing) {
ScrollView {
LazyVStack {
ForEach(0 ..< 20) { _ in
Text("Test")
}
}
}.padding()
}
Button {
self.isShowingNewMessageView.toggle()
} label: {
Image(systemName: "plus.message.fill")
.resizable()
.renderingMode(.template)
.frame(width: 48, height: 48)
.padding()
.foregroundColor(Color.blue)
.sheet(isPresented: $isShowingNewMessageView, content: {
NewMessageView(show: $isShowingNewMessageView, startChat: $showChat)
})
}
}
.onChange(of: showChat) { newValue …Run Code Online (Sandbox Code Playgroud) 我正在开发一个项目,在同事的 iPhone 11 设备(iOS 16.1.1)上运行我们的应用程序时遇到运行时错误:
[lifecycle] [u 68C8D161-6D2A-412E-A4F2-CEDE8D1C83EF:m (null)]
[*PRODUCT_BUNDLE_IDENTIFIER(MARKETING_VERSION)*] RB query for the extension process state failed with error: Error Domain=RBSServiceErrorDomain Code=1
"Client not entitled" UserInfo={RBSEntitlement=com.apple.runningboard.process-state,
NSLocalizedFailureReason=Client not entitled, RBSPermanent=false}
Run Code Online (Sandbox Code Playgroud)
[ PRODUCT_BUNDLE_IDENTIFIER(MARKETING_VERSION) ] 类似于: com.companyName.AppName.Keyboard(1.0.10)
此错误消息仅在加载自定义键盘时出现,并且键盘也是应用程序组的一部分
我检查了 iOS16 发行说明,似乎没有任何内容与此错误相关,我不确定是什么导致了此错误消息?
自从升级到 iPadOS 16 以来,Xcode 的控制台已经充满了诸如[VKImageAnalyzer processRequest:] returned 0或 之类的消息[VKImageAnalyzer processRequest:] block returned NULL analysis- 这发生在模拟器中,并且在物理设备上我收到有关字体的警告,例如CoreText performance note: Client called CTFontCreateWithName() using name "Times-Roman" and got font with PostScript name "TimesNewRomanPSMT". For best performance, only use PostScript names when calling this API.
我的应用程序使用 PDFKit 显示乐谱的 PDF 文件,因此 iOS 16 中引入的 PDF 文件的自动图像分析与其完全无关。除了向控制台发送垃圾邮件之外,此功能还会消耗不必要的资源。
我找不到任何有关禁用 PDFKit 中自动 PDF 分析的方法的文档。任何想法都会非常受欢迎。
当我尝试通过 iPhone 12 Pro 模拟器在 XCode 上启动我的应用程序时,出现以下错误。
\n\n完整的日志是
\nDetails\n\nPseudo Terminal Setup Error\nDomain: IDEPseudoTerminalDomain\nCode: 7\nFailure Reason: ErrorCode: 7 Errno: 6\nUser Info: {\n DVTErrorCreationDateKey = "2023-05-17 14:05:21 +0000";\n IDERunOperationFailingWorker = IDELaunchiPhoneSimulatorLauncher;\n}\n--\nThe operation couldn\xe2\x80\x99t be completed. Device not configured\nDomain: NSPOSIXErrorDomain\nCode: 6\nFailure Reason: Device not configured\n--\n\nAnalytics Event: com.apple.dt.IDERunOperationWorkerFinished : {\n "device_model" = "iPhone13,3";\n "device_osBuild" = "16.4 (20E247)";\n "device_platform" = "com.apple.platform.iphonesimulator";\n "launchSession_schemeCommand" = Run;\n "launchSession_state" = 1;\n "launchSession_targetArch" = arm64;\n "operation_duration_ms" = 50;\n "operation_errorCode" = 7;\n "operation_errorDomain" = IDEPseudoTerminalDomain;\n "operation_errorWorker" = IDELaunchiPhoneSimulatorLauncher;\n …Run Code Online (Sandbox Code Playgroud) 我正在尝试更新旧的应用程序以使用新的 NavigationSplitView 和 NavigationLink,但当侧边栏具有子对象层次结构并且我想从远处更新详细视图时,我试图以正确的方式进行操作子对象。例如,基于 WWDC2022 示例项目 Navigation Cookbook,我尝试了以下操作,但没有成功:
测试应用程序.swift
@main
struct TestApp: App {
@StateObject var appState = AppState()
var body: some Scene {
WindowGroup {
NavigationSplitView {
ProjectListView()
} detail: {
if let chapter = appState.chapter {
ChapterDetailView(chapter: chapter)
} else {
Text("Pick a Chapter")
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
ChapterListView.swift < ProjectListView() 的远亲(向下 3 级)兄弟
List(selection: $appState.chapter) {
ForEach(chapters) { chapter in
NavigationLink(chapter.title ?? "A Chapter", value: chapter)
}
}
Run Code Online (Sandbox Code Playgroud)
appState.swift
class AppState: ObservableObject {
@Published var chapter: …Run Code Online (Sandbox Code Playgroud) swiftui swiftui-navigationlink ios16 swiftui-navigationsplitview ipados16
我们正在开发一种设备,它通过蓝牙 LE 与我们的 iOS/watchOS 应用程序进行通信,并且必须在较长的时间段(数小时)内传输大量传感器数据。在 iOS 15.x 下一切正常,但我们发现 iOS 16 beta(和 RC)在协商过程中改变了一些内容:之前我们使用 15 毫秒的连接间隔,但 iOS 16(和 watchOS 8)最常使用协商的时间为 24 毫秒,这对于我们的带宽来说太宽了。长连接间隔会导致数据包丢失 (9-33%),并且在 3 次失败重试(3x30 秒)后,我们的硬件会断开连接。
我已经检查了所有可用的论坛和文档,但没有发现任何迹象表明某些内容发生了变化。我们可以研究任何新参数来解决这个问题吗?
编辑:将 30 毫秒更改为 24
我需要在最近更新到 iOS 16 的设备上禁用方向更改动画。
对于较旧的 iOS 版本,有一个防止动画的解决方案。使用以下方法禁用动画后,视图层次结构立即发生变化UIView:
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
NSLog(@"breakpoint");
[UIView setAnimationsEnabled:NO];
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
///
}
completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[UIView setAnimationsEnabled:YES];
}];
}
Run Code Online (Sandbox Code Playgroud)
更新到 iOS 16 后,动画似乎在-viewWillTransitionToSize:withTransitionCoordinator:调用之前就开始了。例如,当我在上面的代码中添加断点时,在 iOS 15(及更早版本)上,窗口在到达断点之前将保持不变。在 iOS 16 中,屏幕会在遇到断点之前旋转到新方向。
永久设置[UIView setAnimationsEnabled:NO];,在应用程序启动时会取消其他动画,但方向更改动画仍然会发生。然而,如果永久禁用动画,方向变化动画看起来会更糟,就像只有视角(旋转)有动画,但比例/方面没有动画。