When you set inputAccessoryView AND inputView you get unexpected system UI in between the two custom views
If anyone has a workaround for this I'd love to hear it.
See also: https://stackoverflow.com/questions/79818015/uitextfield-custom-inputaccessoryview-with-custom-inputview-in-ios-26
Red == inputAccessoryView
Blue == inputView
Glassy bit in between == bug?
//
// ViewController.swift
// Custom Keyboard
//
// Created by Lewis Smith on 19/02/2026.
//
import UIKit
class ViewController: UIViewController {
let textField = {
let textField = UITextField()
textField.translatesAutoresizingMaskIntoConstraints = false
textField.backgroundColor = .yellow
let inputAccessoryView = UIView(frame: CGRect(x: 0, y: 0, width: .zero, height: 70))
inputAccessoryView.backgroundColor = .red
let inputView = UIView(frame: CGRect(x: 0, y: 0, width: .zero, height: 70))
inputView.backgroundColor = .blue
// When you set inputAccessoryView AND inputView you get unexpected UI inbetweeen the two custom views
textField.inputAccessoryView = inputAccessoryView
textField.inputView = inputView
textField.becomeFirstResponder()
return textField
}()
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .purple
self.view.addSubview(textField)
NSLayoutConstraint.activate([
textField.centerXAnchor.constraint(equalTo: view.centerXAnchor),
textField.centerYAnchor.constraint(equalTo: view.centerYAnchor),
textField.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
textField.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20),
])
}
}
UIKit
RSS for tagConstruct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi everyone,
I’m running into a strange issue with UISearchController placement with iOS 26 SDK.
In one of my view controllers, I was able to move the search bar to the top of the navigation bar by setting:
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = false
navigationItem.preferredSearchBarPlacement = .stacked
This works as expected — the search bar is placed at the top.
However, in another view controller with almost identical configuration, the search bar always shows up at the bottom. If I delay the setup with DispatchQueue.main.async, it appears at the bottom; if I don’t, it doesn’t appear at all. Both VCs are wrapped in their own UINavigationController.
So my questions are:
Has anyone faced this issue where preferredSearchBarPlacement = .stacked is ignored?
Are there hidden requirements or limitations for placing the search bar at the top?
Why could the same setup behave differently in two controllers?
Any help or ideas would be appreciated!
I'm using one UITabBarController which leads to 6 NavigationController. Therefore the user will get 4 icons displayed and one icon with three points to see the rest of the Navigation Controller.
If the user now tries to edit the list and moves one item from the hidden area towards the TabBar at the bottom, the App crashes with the error:
Exception
NSException * "Can't add self as subview" 0x0000600000d16040
I can see this effect at least on both my apps.
If the same compilation is run on a older iOS version, there is no crash.
Is there anything I have to take care of the configuration of the TabBar, when it comes to iOS26?
Topic:
UI Frameworks
SubTopic:
UIKit
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.
I have an app that records video (and also provides a custom remote interface) so it needs to remain awake and in the foreground.
It sets;
UIApplication.shared.isIdleTimerDisabled = true
I've also tried catching willEnterForegroundNotification to ensure it resets it if the app is backgrounded and resumes;
.onReceive(
NotificationCenter.default.publisher(
for: UIApplication.willEnterForegroundNotification)
) { _ in
UIApplication.shared.isIdleTimerDisabled = true
}
However, it seems that on some devices it will still go to sleep. This seems to be the case when Adaptive Power Mode is on (or rather, I've not managed to reproduce it when Adaptive Power Mode is off) even when battery percentage is well over 20% (I sort of expected Low Power Mode to trigger this)
Am I missing something obvious? there must be a way to make sure media capture apps stay awake (I'm surprised AVFoundation doesn't do it anyway!)
If it is related to Adaptive Power Mode, is there any way to detect that programatically to at least provide a warning to the user that having it on will affect operation of the app?
In my app i need to restrict the user to take screenshot or screen recording .
i used the following code snippet,
let field = UITextField()
let view = UIView(frame: CGRect(x: 0, y: 0, width: field.frame.self.width, height: field.frame.self.height))
// Following view can be customised if required
let newView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height))
newView.backgroundColor = .black
field.isSecureTextEntry = true
window.addSubview(field)
view.addSubview(newView)
window.layer.superlayer?.addSublayer(field.layer)
//field.layer.sublayers?.last!.addSublayer(window.layer)
if let lastSublayer = field.layer.sublayers?.last {
lastSublayer.addSublayer(window.layer)
}
field.leftView = view
field.leftViewMode = .always
My query is will below lines meet the Apple compliance?
will ther be any rejection while publishing to Appstore?
window.layer.superlayer?.addSublayer(field.layer)
field.layer.sublayers?.last!.addSublayer(window.layer).
I have a very simple custom collection view layout that supports self-sizing. When a cell is selected, I expand the cell by modifying its constraints. This change (and the resulting effect on the collection view layout) is animated using [self.collectionView.collectionViewLayout invalidateLayout] followed by [self.collectionView layoutIfNeeded] within an animation closure.
When you first tap on a cell, it expands smoothly as expected. When you tap on it again to contract it, however, its content jumps before it shrinks again. How can I fix this?
For what it’s worth, I’ve noticed that neither UICollectionViewFlowLayout nor UICollectionViewCompositionalLayout have this issue, which suggests I’m doing self-sizing incorrectly.
Here’s a screen recording demonstrating the issue. I’ve also put together a minimal sample project.
I’m using Xcode 26.2 and iOS 26.2.1.
When I use UIScrollView to Browse photos, sometime was crash.
Issue Details:
App: 美信 (Midea Connect)
Problem: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Feedback generator was deactivated by its client more times than it was activated: <_UIZoomEdgeFeedbackGenerator: 0x33527cdc0>' First throw call stack
Affected: 4 user out of thousands
iOS Version: 18.0.1、26.1、26.2
What Works:
All other users has no crash
Same iOS version, no issues
User Has Tried:
The user experienced two crashes after opening the page hundreds of times
Topic:
UI Frameworks
SubTopic:
UIKit
I need to detect whether a view controller is presented in a popover or in fullscreen mode, as on iPhone.
I checked viewController.popoverPresentationController but it returns a non-nil value even on iPhone, when it's clearly not in a popover.
I then checked viewController.presentationController?.adaptivePresentationStyle but it returns .formSheet even when it's presented in a popover!?! Why?
This whole adaptive presentation thingie is a mess. Heck, viewController.presentationController returns _UIPageSheetPresentationController even when the view controller is in a UINavigationController, so not presented at all.
Anybody got any ideas?
There is no way to make an instance of UISegmentedControl transparent like it's done in Photos or Camera. Especially it looks wrong when segmented control is put to a Liquid Glass container.
Setting background colour to nil or clear does not help
If a transparent image is set as a background image for state and bar metrics, it kills liquid glass selection and segments started to look wrong
How can the standard gray-ish background can be removed?
Overview
I have the following view hierarchy that mixes SwiftUI and UIKit:
AccordionView
└─ VStack
├─ Text
├─ Button
└─ UIViewRepresentable
└─ UIStackView
├─ UILabel
└─ UILabel
When tapping the button, the UIViewRepresentable hides and shows its content. This all works as expected.
However, in certain circumstances the view's sizing is rendered with the correct size, but the text can often render incorrectly, despite the frame seemingly looking as though it has enough room to render the text.
More info
Below you can see the UILabel has the correct frame height (the light grey background and coloured borders) but the text is rendered as though it has infinite width along one line.
There's a few configurations of my view hierarchy that seem to have this effect.
I've added a playground to the bottom of this post of various configurations to show what does and doesn't work, just copy and paste to see for yourself...
It seems of the ones that don't work, there's a couple of reasons why that may be:
HostedView and TextViewContainer do not do the following (I think we only need to do one of these things for auto layout/stack views to work effectively):
a) implement an intrinsic content size
b) return a 'good' size for systemLayoutSizeFitting().
UIHostingController shouldn't use intrinsic size (although I'm sure it should)
Something related to setting setContentCompressionResistancePriority() or setContentHuggingPriority() but having played about with this it doesn't seem relevant here...
I've played around with everything I can think of here but can't find a solution that works for all, although I'm 99% sure it's one or all of the points above.
If there are any UIKit gurus out there that can help that would be great! Ive already spent so much time on this 🫨
Playground
Swift Playground
Hello,
I would like to report a potential Dynamic Type rendering issue observed in Control Center.
After increasing the system text size to 100%, the label “My Card” appears visually constrained and partially clipped instead of scaling proportionally according to Dynamic Type guidelines.
Steps to reproduce:
Open Settings
Increase Text Size to 100%
Open Control Center
Observe the “My Card” label
Expected behavior:
The label should scale proportionally using preferred text styles and remain fully visible without truncation.
Observed behavior:
The label appears constrained, suggesting possible fixed height constraints or insufficient layout flexibility.
Technical hypothesis:
This may be caused by:
Fixed height constraints on the text container
Non-preferred font usage instead of dynamic text styles
Missing adjustsFontForContentSizeCategory configuration
Incomplete layout testing across content size categories
Given Apple’s emphasis on accessibility and Dynamic Type compliance, I believe this may be worth reviewing in a future update.
Has anyone else observed similar behavior?
Topic:
UI Frameworks
SubTopic:
UIKit
Since iOS 26, navigationController?.toolbar no longer appears in the view hierarchy, and UIToolbar itself is not visible in the view tree.
Is there currently any supported way to access the toolbar’s container view or its underlying view hierarchy?
However, the API itself is not deprecated.
https://developer.apple.com/documentation/uikit/uinavigationcontroller/toolbar
If I delete Safari and only have another browser installed on my device, UIApplication.shared.open does not work. I think this is a bug. Why would it not work?
If Safari is not the main browser, UIApplication would open the URL in my main browser.
Those are valid use cases.
I would expect this API to work with any browser...
iOS 26.2
iPhone 14 Pro
guard let url = URL(string: "https://www.apple.com") else {
return
}
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
} else {
print("Could not open URL")
}
Topic:
UI Frameworks
SubTopic:
UIKit
Hi!
I am developing a game for iOS using Objective-C and C++.
I am trying to migrate an app to scene-based life cycle, but having a problem while mirroring screen from iPhone to MacBook using AirPlay.
At this moment I don't want to implement multi-window (or multi-scene) support. The only thing I want is to have ability of screen mirroring.
From the documentation from here and here I can't understand which UISceneConfiguration should I return. If I define a UIWindowSceneDelegate for the configuration, how should I handle scene:willConnectToSession:options: if the window has been already created for main device screen? Returning nil is not documented. Is there any examples?
Also, I would expect that defining UIApplicationSupportsMultipleScenes to NO in Info.plist will automatically disable second scene creating. This is mentioned in documentation here, but this is not true, because I still see second scene creation (its pointer differs from one that was already created) in UIWindowSceneDelegate.
What am I doing wrong?
Any hints are highly appreciated!
Topic:
UI Frameworks
SubTopic:
UIKit
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 can't seem to find information on this but this is causing a critical bug where the Strong Password suggestion sheet presents on any secure field (UIKit) and clears the others when closing it. This means the user cannot enter a password when there is a secure confirm password field because switching fields clears the other.
This looks to be a recent issue but I can't tell when this was introduced or if this is SDK / OS version related. I am finding it in both Xcode 26.2 and 16.4 when running on device (iOS 26.2.1 and XC 26 simulators).
Code to reproduce:
class ViewController: UIViewController {
override func loadView() {
let v = UIStackView()
v.axis = .vertical
v.layoutMargins = .init(top: 16, left: 16, bottom: 16, right: 16)
v.isLayoutMarginsRelativeArrangement = true
view = v
let t1 = UITextField()
t1.textContentType = .username
t1.placeholder = "Username"
v.addArrangedSubview(t1)
let t2 = UITextField()
t2.isSecureTextEntry = true
t2.textContentType = .newPassword
t2.placeholder = "Password"
t2.clearsOnInsertion = false
t2.clearsOnBeginEditing = false
t2.passwordRules = nil
t2.clearButtonMode = .always
v.addArrangedSubview(t2)
let t3 = UITextField()
t3.isSecureTextEntry = true
t3.textContentType = .newPassword
t3.placeholder = "Confirm Password"
t3.clearsOnInsertion = false
t3.clearsOnBeginEditing = false
t3.passwordRules = nil
t3.clearButtonMode = .always
v.addArrangedSubview(t3)
v.addArrangedSubview(UIView())
}
}
No matter what textContentType is used the strong password still forcefully breaks the flow and blocks the user.
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?
Platform
UIKit
iOS
UIActivityViewController
Environment
Device (issue reported): iPhone 16
iOS Version: 26.2
App Type: UIKit / Swift (standard modal presentation of UIActivityViewController)
Summary
When presenting UIActivityViewController to share a CSV file, the share sheet does not allow vertical scrolling, making lower actions (including Save to Files) unreachable.
The same flow works correctly when sharing a PDF, and the issue cannot be reproduced on other test devices.
Steps to Reproduce
Launch the app and log in
Navigate to More → Reports
Tap Export Report
Choose Export Report (CSV)
Observe the share sheet
Expected Result
The user should be able to vertically scroll the share sheet
All share actions (including Save to Files) should be reachable
Actual Result
Share sheet opens but vertical scrolling is disabled
Lower options (including Save to Files) are not reachable
No crash or console errors
I run into a layout problem where I cannot center an image inside ScrollView which is also inside Navigation Controller. The problem is surely the fact that there is a navigation bar because using this view without NavigationContoller works fine and the image is centered but I don’t know how to account for the space that navigation bar takes up.
Here is the code:
import UIKit
class PhotoViewController: UIViewController {
var photoName: String
private lazy var photoView = {
let image = UIImageView()
image.translatesAutoresizingMaskIntoConstraints = false
image.contentMode = .scaleAspectFit
image.clipsToBounds = true
return image
}()
var photoViewBottomConstraint: NSLayoutConstraint?
var photoViewLeadingConstraint: NSLayoutConstraint?
var photoViewTopConstraint: NSLayoutConstraint?
var photoViewTrailingConstraint: NSLayoutConstraint?
private lazy var scrollView = {
let sv = UIScrollView()
sv.translatesAutoresizingMaskIntoConstraints = false
return sv
}()
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
updateMinZoomScaleForSize(view.bounds.size)
}
func updateMinZoomScaleForSize(_ size: CGSize) {
let widthScale = size.width / photoView.bounds.width
let heightScale = size.height / photoView.bounds.height
let minScale = min(widthScale, heightScale)
scrollView.minimumZoomScale = minScale
scrollView.zoomScale = minScale
}
func setupUI() {
photoView.image = UIImage(named: photoName)
scrollView.delegate = self
view.addSubview(scrollView)
scrollView.addSubview(photoView)
setupConstraints()
}
func setupConstraints() {
NSLayoutConstraint.activate([
scrollView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
scrollView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
scrollView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
])
photoViewLeadingConstraint = NSLayoutConstraint(
item: photoView,
attribute: .leading,
relatedBy: .equal,
toItem: scrollView,
attribute: .leading,
multiplier: 1,
constant: 0
)
photoViewTopConstraint = NSLayoutConstraint(
item: photoView,
attribute: .top,
relatedBy: .equal,
toItem: scrollView,
attribute: .top,
multiplier: 1,
constant: 0
)
photoViewTrailingConstraint = NSLayoutConstraint(
item: photoView,
attribute: .trailing,
relatedBy: .equal,
toItem: scrollView,
attribute: .trailing,
multiplier: 1,
constant: 0
)
photoViewBottomConstraint = NSLayoutConstraint(
item: photoView,
attribute: .bottom,
relatedBy: .equal,
toItem: scrollView,
attribute: .bottom,
multiplier: 1,
constant: 0
)
photoViewLeadingConstraint?.isActive = true
photoViewTopConstraint?.isActive = true
photoViewTrailingConstraint?.isActive = true
photoViewBottomConstraint?.isActive = true
}
init(photoName: String) {
self.photoName = photoName
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension PhotoViewController: UIScrollViewDelegate {
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
photoView
}
func scrollViewDidZoom(_ scrollView: UIScrollView) {
updateConstraintsForSize(view.bounds.size)
}
func updateConstraintsForSize(_ size: CGSize) {
let yOffset = max(0, (size.height - photoView.frame.height) / 2)
photoViewTopConstraint?.constant = yOffset
photoViewBottomConstraint?.constant = yOffset
let xOffset = max(0, (size.width - photoView.frame.width) / 2)
photoViewLeadingConstraint?.constant = xOffset
photoViewTrailingConstraint?.constant = xOffset
view.layoutIfNeeded()
}
}