I'm trying to revamp the player into a floating style like Apple music. I use tabViewBottomAccessory with tabBarMinimizeBehavior. At the time, I noticed an issue that tabViewBottomAccessory would not automatically collapse when the scroll area was small (but still exceeded the screen height). tabViewBottomAccessory can only be automatically collapsed when the scroll area is large enough. Below is the simplest demo.
I'm not sure if it's intentional or if it's a bug. Besides, I wonder if we can control it programmatically(expanded/inline)?
struct ContentView: View {
var body: some View {
TabView {
Tab("Numbers", systemImage: "number.circle") {
List {
// 200 works well, but 20 not
ForEach(0..<200) { index in
Text("\(index)")
}
}
}
}
.tabBarMinimizeBehavior(.onScrollDown)
.tabViewBottomAccessory {
HStack {
Text("SwiftUI Demo App")
}
}
}
}
Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Simple code like
struct ContentView: View {
@Query var items: [Item]
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
causes UI Hierarchy crash, on Simulators, iPhone and Mac
I found no solution but use @State with fetch descriptor.
With iOS 26.1 and beta 26.2, there is a crash seen for _UIButtonBarItemLayout update. Has anyone experienced this crash or has any information on this
Thread 0 name:
Thread 0 Crashed:
0 libobjc.A.dylib 0x000000019daa144c objc_retain + 16
1 UIKitCore 0x00000001a680b184 -[_UIButtonBarItemLayout _updateItemView] + 360
2 UIKitCore 0x00000001a6d5ddcc -[_UIButtonBarItemLayout minimumLayoutWidthGivenMinimumSpaceWidth:] + 28
3 UIKitCore 0x00000001a6d5eeec -[_UIButtonBarItemGroupLayout recalculateLayoutWidthsGivenItemSpaceWidth:] + 304
4 UIKitCore 0x00000001a6d4ca28 -[_UIButtonBar _widthInfoForLayout:] + 188
5 UIKitCore 0x00000001a68093b4 -[_UIButtonBar _layoutBar] + 108
6 UIKitCore 0x00000001a6809328 __42-[_UIButtonBarStackView updateConstraints]_block_invoke + 44
7 UIKitCore 0x00000001a7dbea8c +[UIView(Animation) performWithoutAnimation:] + 76
8 UIKitCore 0x00000001a68092d0 -[_UIButtonBarStackView updateConstraints] + 112
9 UIKitCore 0x00000001a64707e8 -[UIView(AdditionalLayoutSupport) _previousFittingSizeInfo] + 784
10 UIKitCore 0x00000001a6470508 -[UIView(AdditionalLayoutSupport) _previousFittingSizeInfo] + 48
Topic:
UI Frameworks
SubTopic:
UIKit
Hello,
I'm thinking about how to improve my main tvOS app flow, naively I want to do something like this:
import Combine
import SwiftUI
enum AppState {
case login, onboarding, main
}
class AppStateManager {
let appStatePublisher = PassthroughSubject<AppState, Never>()
func updateState(_ appState: AppState)
}
struct tvOSApp: App {
private var appState: AppState = .login
private let appStateManager = AppStateManager()
var body: some Scene {
WindowGroup {
ZStack {
switch appState {
case .login:
LoginView()
case .onboarding:
OnboardingView()
case .main:
MainView()
}
}
.onReceive(appStateManager.appStatePublisher) {
self.appState = $0
}
}
}
}
So basically, MainView, OnboardingView and LoginView would be the main navigation views of my app, and the appStateManager would be a dependency passed to each of these views and allowing me to update the currently displayed view in the app. (of course I could use an Environment object instead for a 100% SwiftUI solution).
I was wondering, however, if there is a better way to do this, instead of switching in a ZStack, maybe with WindowGroup/Window/Scenes?
Thank you for your help!
Fatal Exception: NSInternalInconsistencyException
Cannot remove an observer <WKWebView 0x135137800> for the key path "configuration.enforcesChildRestrictions" from <STScreenTimeConfigurationObserver 0x13c6d7460>, most likely because the value for the key "configuration" has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the STScreenTimeConfigurationObserver [class.]
I noticed that on iOS 26, WKWebView registers STScreenTimeConfigurationObserver, Is this an iOS 26 system issue? What should I do?
We have an iOS app running on macOS (not Mac Catalyst). The preferences are in a dedicated UIWindowScene. We don't want this scene to be restored, so when you start the app the preferences shouldn't be visible.
How can we prevent the UIWindowScene restoration?
Alternatively, if we can't prevent it, how can we ensure the main window scene is in front of the preferences window scene on app start?
I am working on a Live Activity widget.
In it, I want some of the elements to open different deeplink URLs.
I have found that assigning multiple widgetURL doesn't work, only one of the URLs gets opened no matter where you tap. I also found that Buttons don't seem to do anything, tapping them actually just open my app as if I just tapped a naked Live Activity.
I have found that really only Link elements work if I want to open different URLs upon tapping different elements.
And Links are cool and fine, but I am seeing that on tap, my elements become tinted... As in, there is a highlighted state, and it makes the elements inside blue.
I have tried to use button style API on a link, but it didn't work.
How can I disable the highlighted state for a Link element in a live activity widget?
In iOS 26, when using the liquid glass and the custom clear mode, the pictures of the widgets all display as gray squares and cannot show the actual images anymore.
What should I do to display them?
Hello. I have an 12 year old app that still has some objective-c code in it. I have a place where i have a flip animation between 2 view controllers that looks like this:
[UIView transitionFromView:origView
toView:newViewController.view
duration:0.5
options:UIViewAnimationOptionTransitionFlipFromRight
completion:nil];
It has looked like this since 2012 at least.
In our production release, it works prior to 26.1, but in 26.1 and 26.2, the flip is off-center and looks weird. it's like both edges flip the same way. It's a little bit hard to explain.
If seen at least 2 other app store apps that i have installed behave this way too, from 26.1 and onwards.
Anyone else seen this? Is there anything that can be done about it?
Thankful for thoughts.
I am trying to address an issue with my app’s share sheet where, when the user sends a URL to either Apple Reminders or OmniFocus, the receiving app does not get a title. So I am updating my share sheet code to use UIActivityItemsConfiguration.
I have this code:
let title = "Golden Hill Software"
let url = URL(string: "https://www.goldenhillsoftware.com/")!
let itemProvider = NSItemProvider()
itemProvider.registerObject(ofClass: URL.self, visibility: .all) { (handler) in
handler(url, nil)
return nil
}
let config = UIActivityItemsConfiguration(itemProviders: [itemProvider])
config.metadataProvider = { (key) in
if key == .title || key == .messageBody {
return title
} else {
return nil
}
}
let viewController = UIActivityViewController(activityItemsConfiguration: config)
self.present(viewController, animated: true)
This works with some share sheet extensions. But when I choose the Ivory share extension, Ivory creates a post with a URL that starts with bplist…. When I choose the Open in Chrome action extension, Chrome says “Chrome cannot handle this link”.
Can someone help me understand what I am doing wrong here? (edited)
Topic:
UI Frameworks
SubTopic:
UIKit
inline-code
How do you achieve this effect in toolbar? Where is the documentation for this?
How to make it appear top toolbar or bottom toolbar?
Thank you!
Here is what I have now...
.toolbar {
ToolbarItem(placement: .destructiveAction) {
Button {
showConfirm = true
} label: {
Image(systemName: "trash")
.foregroundColor(.red)
}
}
}
.confirmationDialog(
"Are you sure?",
isPresented: $showConfirm,
titleVisibility: .visible
) {
Button("Delete Item", role: .destructive) {
print("Deleted")
}
Button("Archive", role: .none) {
print("Archived")
}
Button("Cancel", role: .cancel) { }
}
}
As the title says, when I try to add a Toolbar with a Button to my NavigationSplitView I get a warning about satisfying constraints.
Here is a minimal reproducible example:
import SwiftUI
@main
struct ViewTestingApp: App {
var body: some Scene {
WindowGroup {
NavigationSplitView {
Text("Sidebar")
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button {
debugPrint("Hello World!")
} label: {
Label("", systemImage: "flame")
}
}
}
} content: {
Text("Content")
} detail: {
Text("Detail")
}
}
}
}
This is the specific warning I get:
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x600002164960 h=--& v=--& _TtCC5UIKit19NavigationButtonBar15ItemWrapperView:0x100f80fa0.width == 0 (active)>",
"<NSLayoutConstraint:0x600002160370 _TtCC5UIKit19NavigationButtonBar15ItemWrapperView:0x100f80fa0.leading == _UIButtonBarButton:0x100f7d360.leading (active)>",
"<NSLayoutConstraint:0x6000021603c0 H:[_UIButtonBarButton:0x100f7d360]-(0)-| (active, names: '|':_TtCC5UIKit19NavigationButtonBar15ItemWrapperView:0x100f80fa0 )>",
"<NSLayoutConstraint:0x600002160050 'IB_Leading_Leading' H:|-(2)-[_UIModernBarButton:0x100f7e6c0] (active, names: '|':_UIButtonBarButton:0x100f7d360 )>",
"<NSLayoutConstraint:0x6000021600a0 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x100f7e6c0]-(2)-| (active, names: '|':_UIButtonBarButton:0x100f7d360 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000021600a0 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x100f7e6c0]-(2)-| (active, names: '|':_UIButtonBarButton:0x100f7d360 )>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
The project settings are all at their defaults, but in case anyone wants to try it with the whole project:
https://github.com/OddMagnet/ViewTesting
Topic:
UI Frameworks
SubTopic:
SwiftUI
Hi Team,
How do I prevent screenshots using SwiftUI. I was using this solution on UIKit:
extension UIView {
func makeSecure() {
DispatchQueue.main.async {
let protectedView = UIView()
self.superview?.addSubview(protectedView)
// constraints...
let secureView = SecureView()
self.superview?.addSubview(secureView)
// constraints...
secureView.addSecureSubview(self)
// constraints...
}
}
}
class SecureView: UIView {
private lazy var secureField: UIView = {
var secureField: UIView = UIView()
// ...
if let secureContainer = SecureField().secureContainer {
secureField = secureContainer
}
...
return secureField
}()
required init() { ... }
}
Is it posible to do the same thing using SwiftUI. Do we have an example? What would you recommend when we work with confidencial information in SwiftUI like bank account information?
Thanks in advance!
I'm creating an app and I want the user to see the PNG image with the background removed in the widget, but I want the background to be transparent. I've seen this done before in some apps' CarPlay widgets. How can I do this?
Filed https://feedbackassistant.apple.com/feedback/21260457
When a SwiftUI app uses both a DocumentGroupLaunchScene and a TabView (no matter how trivial) in its Content view, it hangs on 26.1 (both simulator and device), with high CPU utilization in
-[UIView(CALayerDelegate) layoutSublayersOfLayer:]
and memory usage increasing rapidly. This did not happen in 26.0
Topic:
UI Frameworks
SubTopic:
SwiftUI
I have checked the sample project from the documentation page
and noticed there is an issue with image/images not being preselected. The issue happens on iOS 26.1 and above (checked iOS 26.2 beta).
I couldn't find any change to the PhotoPicker in the documentation.
Topic:
UI Frameworks
SubTopic:
UIKit
After upgrading to macOS 26, I noticed that showing a Quicklook preview in my app is very slow. Showing small text files is fine, but some other files I've tried, such as a Numbers document, take about 30 seconds (during which the indeterminate loading indicator appears) before the preview is shown. When showing the preview of an app, such as Xcode, the panel opens immediately with a placeholder image for the Xcode icon, and the actual Xcode icon is shown only after about 25 seconds. During this time many logs appear:
FPItemsFromURLsWithTimeout timed out (5.000000s) for: file:///.file/id=6571367.2/ (/)
FPItemsFromURLsWithTimeout timed out (5.000000s) for: file:///.file/id=6571367.23684/ (/Users)
FPItemsFromURLsWithTimeout timed out (5.000000s) for: file:///.file/id=6571367.248032/ (/Users/n{9}k)
FPItemsFromURLsWithTimeout timed out (5.000000s) for: file:///.file/id=6571367.248084/ (/Users/n{9}k/Downloads)
Failed to add registration dmf.policy.monitor.app with error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.dmd.policy was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.dmd.policy was invalidated: failed at lookup with error 159 - Sandbox restriction.}
Failed to register application policy monitor with identifier 69DDBDB4-0736-42FA-BA7A-C8D7EA049E29 for types {(
applicationcategories,
websites,
categories,
applications
)} with error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.dmd.policy was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.dmd.policy was invalidated: failed at lookup with error 159 - Sandbox restriction.}
FPItemsFromURLsWithTimeout timed out (5.000000s) for: file:///.file/id=6571367.155797561/ (~/Downloads/X{3}e.app)
It seems that Quicklook tries to access each parent directory of the previewed file, and each one fails after 5 seconds.
Why is Quicklook all of a sudden so slow? It used to be almost instant in macOS 15.
I created FB20268201.
import Cocoa
import Quartz
@main
class AppDelegate: NSObject, NSApplicationDelegate, QLPreviewPanelDataSource, QLPreviewPanelDelegate {
var url: URL?
func applicationDidFinishLaunching(_ notification: Notification) {
let openPanel = NSOpenPanel()
openPanel.runModal()
url = openPanel.urls[0]
QLPreviewPanel.shared()!.makeKeyAndOrderFront(nil)
}
override func acceptsPreviewPanelControl(_ panel: QLPreviewPanel!) -> Bool {
return true
}
override func beginPreviewPanelControl(_ panel: QLPreviewPanel!) {
panel.dataSource = self
panel.delegate = self
}
override func endPreviewPanelControl(_ panel: QLPreviewPanel!) {
panel.dataSource = nil
panel.delegate = nil
}
func numberOfPreviewItems(in panel: QLPreviewPanel!) -> Int {
return 1
}
func previewPanel(_ panel: QLPreviewPanel!, previewItemAt index: Int) -> QLPreviewItem! {
return url as? QLPreviewItem
}
}
The zoom navigation transition with matchedTransitionSource in tabViewBottomAccessory does not work when a Published var in an ObservableObjector Observable gets changed.
Here is an minimal reproducible example with ObservableObject:
import SwiftUI
import Combine
private final class ViewModel: ObservableObject {
@Published var isPresented = false
}
struct ContentView: View {
@Namespace private var namespace
@StateObject private var viewModel = ViewModel()
// @State private var isPresented = false
var body: some View {
TabView {
Button {
viewModel.isPresented = true
} label: {
Text("Start")
}
.tabItem {
Image(systemName: "house")
Text("Home")
}
Text("Search")
.tabItem {
Image(systemName: "magnifyingglass")
Text("Search")
}
Text("Profile")
.tabItem {
Image(systemName: "person")
Text("Profile")
}
}
.sheet(isPresented: $viewModel.isPresented) {
Text("Sheet")
.presentationDragIndicator(.visible)
.navigationTransition(.zoom(sourceID: "tabViewBottomAccessoryTransition", in: namespace))
}
.tabViewBottomAccessory {
Button {
viewModel.isPresented = true
} label: {
Text("BottomAccessory")
}
.matchedTransitionSource(id: "tabViewBottomAccessoryTransition", in: namespace)
}
}
}
However, when using only a State property everything works:
import SwiftUI
import Combine
private final class ViewModel: ObservableObject {
@Published var isPresented = false
}
struct ContentView: View {
@Namespace private var namespace
// @StateObject private var viewModel = ViewModel()
@State private var isPresented = false
var body: some View {
TabView {
Button {
isPresented = true
} label: {
Text("Start")
}
.tabItem {
Image(systemName: "house")
Text("Home")
}
Text("Search")
.tabItem {
Image(systemName: "magnifyingglass")
Text("Search")
}
Text("Profile")
.tabItem {
Image(systemName: "person")
Text("Profile")
}
}
.sheet(isPresented: $isPresented) {
Text("Sheet")
.presentationDragIndicator(.visible)
.navigationTransition(.zoom(sourceID: "tabViewBottomAccessoryTransition", in: namespace))
}
.tabViewBottomAccessory {
Button {
isPresented = true
} label: {
Text("BottomAccessory")
}
.matchedTransitionSource(id: "tabViewBottomAccessoryTransition", in: namespace)
}
}
}
Hello there!
I wanted to give a native scrolling mechanism for the Swift Charts Graph a try and experiment a bit if the scenario that we try to achieve might be possible, but it seems that the Swift Charts scrolling performance is very poor.
The graph was created as follows:
X-axis is created based on a date range,
Y-axis is created based on an integer values between moreless 0-320 value.
the graph is scrollable horizontally only (x-axis),
The time range (x-axis) for the scrolling content was set to one year from now date (so the user can scroll one year into the past as a minimum visible date (.chartXScale).
The X-axis shows 3 hours of data per screen width (.chartXVisibleDomain).
The data points for the graph are generated once when screen is about to appear so that the Charts engine can use it (no lazy loading implemented yet).
The line data points (LineMark views) consist of 2880 data points distributed every 5 minutes which simulates - two days of continuous data stream that we want to present. The rest of the graph displays no data at all.
The performance result:
The graph on the initial loading phase is frozen for about 10-15 seconds until the data appears on the graph.
Scrolling is very laggy - the CPU usage is 100% and is unacceptable for the end users.
If we show no data at all on the graph (so no LineMark views are created at all) - the result is similar - the empty graph scrolling is also very laggy.
Below I am sharing a test code:
@main
struct ChartsTestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
Spacer()
}
}
}
struct LineDataPoint: Identifiable, Equatable {
var id: Int
let date: Date
let value: Int
}
actor TestData {
func generate(startDate: Date) async -> [LineDataPoint] {
var values: [LineDataPoint] = []
for i in 0..<(1440 * 2) {
values.append(
LineDataPoint(
id: i,
date: startDate.addingTimeInterval(
TimeInterval(60 * 5 * i) // Every 5 minutes
),
value: Int.random(in: 1...100)
)
)
}
return values
}
}
struct ContentView: View {
var startDate: Date {
return endDate.addingTimeInterval(-3600*24*30*12) // one year into the past from now
}
let endDate = Date()
@State var dataPoints: [LineDataPoint] = []
var body: some View {
Chart {
ForEach(dataPoints) { item in
LineMark(
x: .value("Date", item.date),
y: .value("Value", item.value),
series: .value("Series", "Test")
)
}
}
.frame(height: 200)
.chartScrollableAxes(.horizontal)
.chartYAxis(.hidden)
.chartXScale(domain: startDate...endDate) // one year possibility to scroll back
.chartXVisibleDomain(length: 3600 * 3) // 3 hours visible on screen
.onAppear {
Task {
dataPoints = await TestData().generate(startDate: startDate)
}
}
}
}
I would be grateful for any insights or suggestions on how to improve it or if it's planned to be improved in the future.
Currently, I use UIKit CollectionView where we split the graph into smaller chunks of the graph and we present the SwiftUI Chart content in the cells, so we use the scrolling offered there. I wonder if it's possible to use native SwiftUI for such a scenario so that later on we could also implement some kind of lazy loading of the data as the user scrolls into the past.
The Widget Image display on iOS26 transparency mode is blank
Both of these writing methods show blank Spaces. Is there a problem with my code or a bug in the system?
The current compilation environment is Xcode Version 16.3 (16E140) iOS26.0