I’m trying to understand the expected behavior of TabView when using .tabViewStyle(.page) on iPadOS with a hardware keyboard.
When I place a TabView in page mode, swipe gestures correctly move between pages. However, left and right arrow keys do nothing by default, even when the view is made focusable. This feels a bit surprising, since paging with arrow keys seems like a natural keyboard interaction when a keyboard is attached.
Right now, to get arrow-key navigation working, I have to manually:
Make the view focusable
Listen for arrow key presses
Update the selection state manually
This works, but it feels a little tedious for something that seems like it could be built-in.
import SwiftUI
struct PageTabsExample: View {
@State private var selection = 0
private let pageCount = 3
var body: some View {
TabView(selection: $selection) {
Color.red.tag(0)
Color.blue.tag(1)
Color.green.tag(2)
}
.tabViewStyle(.page)
.indexViewStyle(.page)
.focusable(true)
.onKeyPress(.leftArrow) {
guard selection > 0 else { return .ignored }
selection -= 1
return .handled
}
.onKeyPress(.rightArrow) {
guard selection < pageCount - 1 else { return .ignored }
selection += 1
return .handled
}
}
}
My questions:
Is this lack of default keyboard paging for page-style TabView intentional on iPadOS with a hardware keyboard?
Is there a built-in way to enable arrow-key navigation for page-style TabView, or is manual handling the expected approach?
Does my approach above look like the “SwiftUI-correct” way to do this, or is there a better pattern for integrating keyboard navigation with paging?
For this kind of behavior, is it generally recommended to use .onKeyPress like I’m doing here, or would .keyboardShortcut be more appropriate (for example, wiring arrow keys to actions instead)?
Any guidance or clarification would be greatly appreciated. I just want to make sure I’m not missing a simpler or more idiomatic solution.
Thanks!
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
Looking to see if anyone has experienced this issue, and is aware of any workarounds.
With an app migrating towards SwiftUI Views but still using UIKit for primary navigation, my app makes use of UIHostingController to push SwiftUI Views onto a UINavigationController stack in a lot of areas. With iOS 26, I notice that SwiftUI's Menu view really struggles to present when contained in a UIHostingController. An error is logged to the console on presentation, and depending on the UI, the Menu won't present inside of it's container, or will jump around the screen.
The bug, it seems is based in a private class UIReparentingView and I am curious if anyone has found a work around for this issue. The error reported is:
Adding '_UIReparentingView' as a subview of UIHostingController.view is not supported and may result in a broken view hierarchy. Add your view above UIHostingController.view in a common superview or insert it into your SwiftUI content in a UIViewRepresentable instead.
The simplest way to see this issue is to create a new storyboard based project. From the ViewController present a UIHostingController with a SwiftUI view that has a Menu and then simply tap to open the Menu. Thanks for any input!
I’m working with CPListTemplate in CarPlay and have run into two issues:
Item limit: The documentation states that maximumItemCount is 500. In practice, when providing a list of ~2–4k items, only the first 500 are displayed. However, Apple Music on CarPlay seems to handle larger lists without this limitation. Is there an API-level approach or recommended pattern to support lists beyond this cap?
Image memory usage: Cells don’t appear to load lazily. Even with small images, the first 500 items load all their artwork into memory immediately, resulting in ~400–700 MB usage and high CPU loads. This seems excessive for CarPlay environments. Is there a best practice for deferring or managing image loading within CPListTemplate?
Any official guidance or known workarounds for these two issues would be very helpful.
I'd like to investigate creating a safety feature for Type 1 Diabetics driving a car. Allowing HealthKit glucose data (read from a Dexcom G7 or similar) to be displayed as part of the CarPlay UI background or show an icon/button with the number visible. I'd also like to include a warning system for glucose low's that alerts the driver audibly. Has anyone looked into that before?
CPListTemplate
item.playing = YES;
item.playingIndicatorLocation = CPListItemPlayingIndicatorLocationTrailing;
iOS 26: The playing indicator shows only a static icon when initially displayed in the list. The animation requires the cell to be scrolled off-screen and back into view to render correctly.
I am having an issue with the code that I posted below. I capture voice in my CarPlay app, then allow the user to have it read back to them using AVSpeechUtterance.
This works fine on some cars, but many of my beta testers report no audio being played. I have also experienced this in a rental car where the audio was either too quiet or the audio didn't play.
Does anyone see any issue with the code that I posted? This is for CarPlay specifically.
class CarPlayTextToSpeechService: NSObject, ObservableObject, AVSpeechSynthesizerDelegate {
private var speechSynthesizer = AVSpeechSynthesizer()
static let shared = CarPlayTextToSpeechService()
/// Completion callback
private var completionCallback: (() -> Void)?
override init() {
super.init()
speechSynthesizer.delegate = self
}
func configureAudioSession() {
do {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .voicePrompt, options: [.duckOthers, .interruptSpokenAudioAndMixWithOthers, .allowBluetoothHFP])
} catch {
print("Failed to set audio session category: \(error.localizedDescription)")
}
}
public func speak(_ text: String, completion: (() -> Void)? = nil) {
self.configureAudioSession()
// Store the completion callback
self.completionCallback = completion
Task(priority: .high) {
let speechUtterance = AVSpeechUtterance(string: text)
let langCode = Locale.preferredLocalLanguageCountryCode
if langCode == "en-US" {
speechUtterance.voice = AVSpeechSynthesisVoice(identifier: AVSpeechSynthesisVoiceIdentifierAlex)
} else {
speechUtterance.voice = AVSpeechSynthesisVoice(language: langCode)
}
try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation)
speechSynthesizer.speak(speechUtterance)
}
}
func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didFinish utterance: AVSpeechUtterance) {
Task {
stopSpeech()
try AVAudioSession.sharedInstance().setActive(false)
}
// Call completion callback if available
self.completionCallback?()
self.completionCallback = nil
}
func stopSpeech() {
speechSynthesizer.stopSpeaking(at: .immediate)
}
}
I am trying to implement a common UX/UI pattern: one view with rounded corners transitioning to a view that fills the screen (N.B. having the display's corner radius).
I got this to work if both corner radiuses are equal to that of the display (see first GIF).
However, I cannot seem to get it to work for arbitrary corner radiuses of the smaller view (i.e., the one that does not fill the screen).
I expected the be able to combine ContainerRelativeShape with .containerShape (see code), but this left me with a broken transition animation (see second GIF).
import SwiftUI
struct ContentView: View {
@Namespace private var animation
@State private var selectedIndex: Int?
var body: some View {
ZStack {
if let selectedIndex = selectedIndex {
ContainerRelativeShape()
.fill(Color(uiColor: .systemGray3))
.matchedGeometryEffect(id: "square-\(selectedIndex)", in: animation)
.ignoresSafeArea()
.onTapGesture {
withAnimation() {
self.selectedIndex = nil
}
}
.zIndex(1)
}
ScrollView {
VStack(spacing: 16) {
ForEach(0..<20, id: \.self) { index in
if selectedIndex != index {
ContainerRelativeShape() // But what if I want some other corner radius to start with?
.fill(Color(uiColor: .systemGray5))
.matchedGeometryEffect(id: "square-\(index)", in: animation)
.aspectRatio(1, contentMode: .fit)
.padding(.horizontal, 12)
.onTapGesture {
withAnimation() {
selectedIndex = index
}
}
// .containerShape(RoundedRectangle(cornerRadius: 20))
// I can add this to change the corner radius, but this breaks the transition of the corners
} else {
Color.clear
.aspectRatio(1, contentMode: .fit)
.padding(.horizontal, 12)
}
}
}
.padding(.vertical, 16)
}
}
}
}
#Preview {
ContentView()
}
What am I missing here? How can I get this to work? And where is the mistake in my reasoning?
Since updating to Tahoe and Xcode 26 I have found that the UISplitViewController.showDetailViewController() is not working in the iPhone version of my app (it is a universal app). I'm just trying to show a detail view after a tap on a UITableView item. The iPad versions are all working correctly. Has anyone else experienced this or have any advice about what may have changed?
Thanks in advance.
We have submitted a feedback for this issue: FB21230723
We're building a note-taking app for iOS and macOS that uses both UITextView and NSTextView.
When performing text input that involves a marked range (such as Japanese input) in a UITextView or NSTextView with a UITextViewDelegate or NSTextViewDelegate set, the text view's marked range (markedTextRange / markedRange()) has not yet been updated at the moment when shouldChangeTextIn is invoked.
UITextViewDelegate.textView(_:shouldChangeTextIn:replacementText:)
NSTextViewDelegate.textView(_:shouldChangeTextIn:replacementString:)
The current behavior is this when entering text in Japanese: (same for NSTextView)
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
print(textView.markedTextRange != nil) // prints out false
DispatchQueue.main.async {
print(textView.markedTextRange != nil) // prints out true
}
}
However, we need the value of markedTextRange right away in order to determine whether to return true or false from this method.
Is there any workaround for this issue?
The Paste button (using UIPasteControll) located on UINavigationBar is not shown at application startup on iOS/iPadOS 26.
This issue will disappear when device is rotated or window size is changed.
And this issue does not occur on iOS / iPadOS 18 and earlier.
I uploaded the sample project to github at the following URL. https://github.com/gpn-galapagos/PasteButtonApp.git
Has anyone had the same issue or knows a workaround?
Description:
I’m encountering an issue where the Apple Watch’s watchOS version is lower than the deployment target specified in my Xcode project.
For example, my Watch device is running watchOS 10.6, but my app’s deployment target is set to watchOS 9.6 or 10.6, and Xcode shows an error stating:
Error: “watchOS version doesn’t match the app’s deployment target.”
Could someone clarify how to properly handle this version mismatch?
Environment:
Xcode 26
iPhone: iOS 18
Apple Watch: watchOS 10.6
Any guidance or best practices would be appreciated.
The Problem
When using adjustsImageWhenAncestorFocused = true on a UIImageView in tvOS, the native focus halo effect does not respect the cornerRadius property set on the image view's layer.
The image itself correctly clips to the rounded corners, but the focus halo (the glowing outline that appears when the view is focused) always renders with square or nearly-square corners.
Code Example
let imageView = UIImageView()
imageView.layer.cornerRadius = 60
imageView.clipsToBounds = true
imageView.adjustsImageWhenAncestorFocused = true
imageView.image = posterImage
Result: The poster image displays with 60pt rounded corners as expected, but when focused, the halo effect has square corners - creating an obvious visual mismatch.
Expected Behavior
The focus halo should follow the same cornerRadius as the UIImageView. If I set a 60pt corner radius, both the image and its focus halo should have matching 60pt rounded corners.
Actual Behavior
The image respects cornerRadius and displays with rounded corners
The focus halo ignores cornerRadius and renders with square corners
This creates an inconsistent, unpolished appearance
Environment
tvOS 16.0+ (tested through tvOS 18)
Affects both Apple TV Simulator and physical devices
Occurs with any corner radius value above approximately 20-30pt
Use Case
This is a common scenario for media streaming apps. Movie and TV show poster cards typically use rounded corners (40-80pt) as part of modern UI design. Many apps like Netflix, Plex, and others use this design pattern.
The current behavior forces developers to choose between:
Using the beautiful native focus effect but with mismatched square halos
Implementing a completely custom focus effect from scratch, losing the native parallax, shadow, and halo animations
Neither option is ideal.
What I've Tried
Setting cornerRadius before and after adjustsImageWhenAncestorFocused
Different clipsToBounds configurations
Wrapping the image view in a container view with corner radius
Using layer.maskedCorners to specify which corners to round
Subclassing CALayer to intercept sublayers added by the focus system
None of these approaches affect the focus halo's corner radius.
Request
I would appreciate guidance on any of the following:
Is there a supported way to customize the focus halo's corner radius? The UIFocusHaloEffect class exists on iOS/iPadOS but is not available on tvOS.
Is this a bug that will be addressed? The focus system clearly reads some properties from the image view (like bounds), so it seems like cornerRadius should also be respected.
Is there a different API I should be using? Perhaps there's an alternative approach to achieve rounded corner poster cards with matching focus effects that I'm not aware of.
Additional Context
I've noticed that some third-party apps have achieved this effect, suggesting it may be possible through undocumented means. However, I would prefer to use a public, supported API to ensure compatibility with future tvOS updates.
Any guidance from Apple engineers or developers who have solved this would be greatly appreciated.
Thank you.
Topic:
UI Frameworks
SubTopic:
UIKit
AI's would have me believe that the header of a TableColumn in Table() can be modified to be interactive simply by adding a header: closure with a Button however no provided code actually compiles or reflects any documentation I can find.
Is it possible to put something besides a Text object in the header?
Topic:
UI Frameworks
SubTopic:
SwiftUI
After the iOS 26 update, unwanted animations appear on UIButton.
I'm using the attributedTitle property of UIButton.Configuration to change the button's text, and an animation appears after iOS 26.
(It's unclear whether it's after iOS 26.0 or iOS 26.1, but it likely started with 26.1.)
The peculiar thing is that the animation only starts appearing on buttons that have been pressed once.
I tried using UIView.performWithoutAnimation and CATransaction's begin(), setDisableActions(true), commit(), but it didn't work.
How should I solve this?
Below is the code for changing the button's text.
func updateTitle() {
let keys = type.keys
if keys.count == 1 {
guard let key = keys.first else { return }
if key.count == 1 {
if Character(key).isLowercase {
self.configuration?.attributedTitle = AttributedString(key, attributes: AttributeContainer([.font: UIFont.systemFont(ofSize: 24, weight: .regular), .foregroundColor: UIColor.label]))
} else if Character(key).isUppercase {
self.configuration?.attributedTitle = AttributedString(key, attributes: AttributeContainer([.font: UIFont.systemFont(ofSize: 22, weight: .regular), .foregroundColor: UIColor.label]))
} else {
self.configuration?.attributedTitle = AttributedString(key, attributes: AttributeContainer([.font: UIFont.systemFont(ofSize: 22, weight: .regular), .foregroundColor: UIColor.label]))
}
} else {
self.configuration?.attributedTitle = AttributedString(key, attributes: AttributeContainer([.font: UIFont.systemFont(ofSize: 18, weight: .regular), .foregroundColor: UIColor.label]))
}
} else {
let joined = keys.joined(separator: "")
self.configuration?.attributedTitle = AttributedString(joined, attributes: AttributeContainer([.font: UIFont.systemFont(ofSize: 22, weight: .regular), .foregroundColor: UIColor.label]))
}
}
Why is the UIKeyboard implementation still holding a reference to this UITextField, thus keeping it from being deallocated?
The memory debugger shows:
UIKeyboardImpl -> UIKBAutofillController -> NSMutableDictionary -> NSMutable...(Storage) -> UITextField
Any idea what's going on there?
Hi there!
We have an application that exists for more than 10 years (Appkit, Obj-C), and since the very beginning we're using CMD+ESC as a keyboard shortcut for a very important function in our app. Until now, this worked great.
Recently, when macOS 26.1 released our app started to not responding to CMD+ESC anymore for some of our customers - it seems like CMD+ESC never gets to our app at all. First, we though it's happening because Game Overlay is also using CMD+ESC by default, but when we turned that off, or switched that to something else in macOS's Keyboard preferences, the issue still persisted.
The, we realized this has something to do with iCloud - so, if you turn off iCloud, do a log out and log in to your computer, and it's magically starts working again, as it always did.
More strangely, this issue doesn't happen for everyone - for many of our customers, the issue seems to doesn't exist for some strange reason.
Anyone have any idea what could be happening here?
Topic:
UI Frameworks
SubTopic:
AppKit
Dear Forum,
after decades, I'm back to MacOS dev just for the need of it. Besides Mac, I'm also toying around with vintage IBM mainframe systems and therefore I'm in need for a good terminal emulation. So far, I use x3270 on my Apple Silicon M1 MacBook Air - nice. However, I can't compile it on my collection of vintage Macs (iMac G3, Cube G4) so I pondered to create it on my own using Cocoa (starting with MacOS X 10.4 Tiger up to the current level (on Sequoia) so that rules out Carbon. tn3270 X from Brown University works nice on those vintage Macs but misses some features. Having browsed some info about the Cocoa Text system, I wonder if that would be the right place to start.
At the end of the day, I need to be able to intercept all keystrokes, have more or less a fixed font 80x25 (136x25 etc..) col/row layout of protected and unprotected areas where text can be entered. Cusor should be visible and movable by using cursor control keys. I'd be happy for any suggestion on where to start here.
Kind regards
Michael
Topic:
UI Frameworks
SubTopic:
AppKit
On macOS I'm seeing that only one .fileImporter modifier is called when two are defined. Anybody seeing the same issue?
The scenario I have is two different file sources share the same file extension but they need to be loaded by two slightly different processes.
Select the first option. Nothing happens. Select the second option, it works. Seeing this also in another project.
Because the isPresented value is a binding, it isn't straightforward to logically OR the boolean @States and conditionally extract within the import closure.
@main
struct Dual_File_Importer_ExpApp: App {
@State private var showFirstDialog = false
@State private var showSecondDialog = false
var body: some Scene {
DocumentGroup(newDocument: Dual_File_Importer_ExpDocument()) { file in
ContentView(document: file.$document)
.fileImporter(isPresented: $showFirstDialog, allowedContentTypes: [.commaSeparatedText]) { result in
print("first")
}
.fileImporter(isPresented: $showSecondDialog, allowedContentTypes: [.commaSeparatedText]) { result in
print("second")
}
}
.commands {
CommandGroup(after: .importExport)
{
Button("Import First")
{
showFirstDialog.toggle()
}
Button("Import Second")
{
showSecondDialog.toggle()
}
}
}
}
}```
Topic:
UI Frameworks
SubTopic:
SwiftUI
Hi all,
when I launch my macOS app from Xcode 16 on ARM64, appKit logs me this error on the debug console:
It's not legal to call -layoutSubtreeIfNeeded on a view which is already being laid out. If you are implementing the view's -layout method, you can call -[super layout] instead. Break on _NSDetectedLayoutRecursion(void) to debug. This will be logged only once. This may break in the future.
_NSDetectedLayoutRecursion doesn't help a lot, giving me these assembly codes from a call to a subclassed window method that looks like this:
-(void) setFrame:(NSRect)frameRect display:(BOOL)flag {
if (!_frameLocked) [super setFrame:frameRect display:flag];
}
I have no direct call to -layoutSubtreeIfNeeded from a
-layout implementation in my codes. I have a few calls to this method from update methods, however even if I comment all of them, the error is still logged...
Finally, apart from that log, I cannot observe any layout error when running the program. So I wonder if this error can be safely ignored?
Thanks!
It seems to be that the functionality of the method setViewController:forColumn: in the column-style layout of a UISplitViewController has changed.
iOS 18: setViewController:forColumn: pushes a new view controller onto the UINavigationController if it existed before the call.
iOS 26: setViewController:forColumn: sets or replaces the view controller with a new view controller as a root of a new UINavigationController.
My questions:
what is the intended behavior? I did not find any documentation about a change.
how do I replace in iOS 18 the old view controller with the new view controller passed to setViewController:forColumn:?