We're encountering a UX challenge with the automatic App Store notification banner that appears when users first launch our App Clips (not the App Clip sheet). This notification, which suggests downloading the full app, is creating confusion among our users. We've observed that some users tap the notification instead of completing their intended action within the App Clip, interrupting their workflow.
Is there a way to disable this banner?
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
Hello,
is there a way to implement Continuity Markup in our own apps?
(This is what I'm talking about: https://support.apple.com/en-us/102269 , scroll down to "Use Continuity Markup").
Also, why does a QuickLook panel (QLPreviewPanel.shared()) not display the markup options when triggered from my app for png image files in my app's Group Container? Do I need to implement certain NSServicesMenuRequestor methods for that?
Sadly, I could not find any docs on that.
Thank you,
– Matthias
My SwiftUI app uses an Image with a tap gesture:
Image(systemName: "xmark.circle.fill")
.accessibilityIdentifier(kTextFieldClearButton)
.foregroundColor(.secondary)
.padding(.trailing, 6)
.onTapGesture {
dataSource.textFieldText = ""
}
In a UI test, I want to tap this image to execute its action:
let clearButton = app.images[kTextFieldClearButton]
clearButton.tap()
However the action is not executed.
I then set a breakpoint at clearButton.tap(), to execute lldb commands. Here are the results:
(lldb) p clearButton.isHittable
t = 439.54s Find the "TextFieldClearButton" Imag
(Bool) true
e
It is a little strange that "Image" has been interrupted by (Bool) true, but the image is hittable.
p clearButton.isAccessibilityElement
gives
(lldb) p clearButton.isAccessibilityElement
(Bool) false
I don't understand why this Image is no accessibility element. I thought, SwiftUI Views are by default accessible.
What can I do to make it accessible so that clearButton.tap() works as expected?
I am facing same issue with major crash while coming out from this function.
Basically using collectionView.dequeReusableCell with size calculation.
func getSizeOfFavouriteCell(_ collectionView: UICollectionView, at indexPath: IndexPath, item: FindCircleInfoCellItem) -> CGSize { guard let dummyCell = collectionView.dequeueReusableCell( withReuseIdentifier: TAButtonAddCollectionViewCell.reuseIdentifier, for: indexPath) as? TAButtonAddCollectionViewCell else { return CGSize.zero }
dummyCell.title = item.title
dummyCell.subtitle = item.subtitle
dummyCell.icon = item.icon
dummyCell.layoutIfNeeded()
var targetSize = CGSize.zero
if viewModel.favoritesDataSource.isEmpty.not,
viewModel.favoritesDataSource.count > FindSheetViewControllerConstants.minimumFavoritesToDisplayInSection {
targetSize = CGSize(width: collectionView.frame.size.width / 2, height: collectionView.frame.height)
var estimatedSize: CGSize = dummyCell.systemLayoutSizeFitting(targetSize)
if estimatedSize.width > targetSize.width {
estimatedSize.width = targetSize.width
}
return CGSize(width: estimatedSize.width, height: targetSize.height)
}
}
We have resolve issue with size calculation with checking nil. Working fine in xcode 15 and 16+.
Note: Please help me with reason of crash? Is it because of xCode 16.2 onwards **strict check on UICollectionView **
I want use SensorKit data for research purposes in my current app.
I have applied for and received permission from Apple to access SensorKit Data. I have granting all the necessary permissions. But no data retrieved.
I am using didCompleteFetch for retrieving data from Sensorkit. CompleteFetch method calls but find the data. Below is my SensorKitManager Code.
import SensorKit
import Foundation
protocol SensorManagerDelegate: AnyObject {
func didFetchPhoneUsageReport(_ reports: [SRPhoneUsageReport])
func didFetchAmbientLightSensorData(_ data: [SRAmbientLightSample])
func didFailFetchingData(error: Error)
}
class SensorManager: NSObject, SRSensorReaderDelegate {
private let phoneUsageReader: SRSensorReader
private let ambientLightReader: SRSensorReader
weak var delegate: SensorManagerDelegate?
override init() {
self.phoneUsageReader = SRSensorReader(sensor: .phoneUsageReport)
self.ambientLightReader = SRSensorReader(sensor: .ambientLightSensor)
super.init()
self.phoneUsageReader.delegate = self
self.ambientLightReader.delegate = self
}
func requestAuthorization() {
let sensors: Set<SRSensor> = [.phoneUsageReport, .ambientLightSensor]
guard phoneUsageReader.authorizationStatus != .authorized || ambientLightReader.authorizationStatus != .authorized else {
log("Already authorized. Fetching data directly...")
fetchSensorData()
return
}
SRSensorReader.requestAuthorization(sensors: sensors) { [weak self] error in
DispatchQueue.main.async {
if let error = error {
self?.log("Authorization failed: \(error.localizedDescription)", isError: true)
self?.delegate?.didFailFetchingData(error: error)
} else {
self?.log("Authorization granted.")
self?.fetchSensorData()
}
}
}
}
func fetchSensorData() {
guard let fromDate = Calendar.current.date(byAdding: .day, value: -1, to: Date()) else {
log("Failed to calculate 'from' date.", isError: true)
return
}
let fromTime = SRAbsoluteTime.fromCFAbsoluteTime(_cf: fromDate.timeIntervalSinceReferenceDate)
let toTime = SRAbsoluteTime.fromCFAbsoluteTime(_cf: Date().timeIntervalSinceReferenceDate)
let phoneUsageRequest = SRFetchRequest()
phoneUsageRequest.from = fromTime
phoneUsageRequest.to = toTime
phoneUsageRequest.device = SRDevice.current
let ambientLightRequest = SRFetchRequest()
ambientLightRequest.from = fromTime
ambientLightRequest.to = toTime
ambientLightRequest.device = SRDevice.current
phoneUsageReader.fetch(phoneUsageRequest)
ambientLightReader.fetch(ambientLightRequest)
}
// ✅ Delegate Methods
func sensorReader(_ reader: SRSensorReader, didCompleteFetch fetchRequest: SRFetchRequest) {
Task.detached {
if reader.sensor == .phoneUsageReport {
if let samples = reader.fetch(fetchRequest) as? [SRPhoneUsageReport] {
DispatchQueue.main.async { [weak self] in
self?.delegate?.didFetchPhoneUsageReport(samples)
}
}
} else if reader.sensor == .ambientLightSensor {
if let samples = reader.fetch(fetchRequest) as? [SRAmbientLightSample] {
DispatchQueue.main.async { [weak self] in
self?.delegate?.didFetchAmbientLightSensorData(samples)
}
}
}
}
}
func sensorReader(_ reader: SRSensorReader, fetching fetchRequest: SRFetchRequest, didFetchResult result: SRFetchResult<AnyObject>) -> Bool {
return true
}
func sensorReader(_ reader: SRSensorReader, fetching fetchRequest: SRFetchRequest, failedWithError error: any Error) {
DispatchQueue.main.async { [weak self] in
self?.delegate?.didFailFetchingData(error: error)
}
}
// MARK: - Logging Helper
private func log(_ message: String, isError: Bool = false) {
if isError {
print("❌ [SensorManager] \(message)")
} else {
print("✅ [SensorManager] \(message)")
}
}
}
And ViewController
import UIKit
import SensorKit
class ViewController: UIViewController {
private var sensorManager: SensorManager!
override func viewDidLoad() {
super.viewDidLoad()
setupSensorManager()
}
private func setupSensorManager() {
sensorManager = SensorManager()
sensorManager.delegate = self
sensorManager.requestAuthorization()
}
}
// MARK: - SensorManagerDelegate
extension ViewController: SensorManagerDelegate {
func didFetchPhoneUsageReport(_ reports: [SRPhoneUsageReport]) {
for report in reports {
print("Total Calls: (report.totalOutgoingCalls + report.totalIncomingCalls)")
print("Outgoing Calls: (report.totalOutgoingCalls)")
print("Incoming Calls: (report.totalIncomingCalls)")
print("Total Call Duration: (report.totalPhoneCallDuration) seconds")
}
}
func didFetchAmbientLightSensorData(_ data: [SRAmbientLightSample]) {
for sample in data {
print(sample)
}
}
func didFailFetchingData(error: Error) {
print("Failed to fetch data: \(error.localizedDescription)")
}
}
Could anyone please assist me in resolving this issue? Any guidance or troubleshooting steps would be greatly appreciated.
How should I program the globe key? If possible, could you teach me in C language?
Topic:
UI Frameworks
SubTopic:
General
I currently face an Issue where the SafeAreaInsets on the iPhone 16 Pro Max is not respected on LaunchScreens.
Lets say you have an ImageView whose leading, trailing and top are equal to the SafeAreaLayoutGuides leading, trailing and top.
Then you have a SwiftUI View such as the following representing the same layout in code:
GeometryReader { reader in
ZStack {
VStack(spacing: 0) {
Spacer(minLength: 0)
.frame(height: reader.safeAreaInsets.top)
Image(decorative: "splashLogo")
Spacer(minLength: 0)
}
.frame(width: reader.size.width)
}
.edgesIgnoringSafeArea(.all)
}
Both the storyboard preview as well as the SwiftUI preview show identical results in Xcode. Launching the app on the device however briefly shows the image below the Dynamic Island cutout until the app is launched to the SwiftUI view. Noticed this only happening on the iPhone 16 Pro Max.
Topic:
UI Frameworks
SubTopic:
General
Hi Apple team and community,
We’re encountering a strange issue with Live Activity that seems related to memory management or background lifecycle.
❓ Issue:
Our app updates a Live Activity regularly (every 3 minutes) using .update(...). However, after the app remains in the background for around 8 hours, the Live Activity reverts to the initial state that was passed into .request(...).
Even though the app continues sending updates in the background, the UI on the Lock Screen and Dynamic Island resets to the original state.
I'm trying to determine if it’s possible to detect when a user interacts with a Slide Over window while my app is running in the background on iPadOS. I've explored lifecycle methods such as scenePhase and various UIApplication notifications (e.g., willResignActiveNotification) to detect focus loss, but these approaches don't seem to capture the event reliably. Has anyone found an alternative solution or workaround for detecting this specific state change? Any insights or recommended practices would be greatly appreciated.
为什么App 上传testFlight之后。无法通过NFC的方式唤醒 APP Clips。是必须要上架商店之后才能支持么?
Hi,
I see some apps like LinkedIn that doesn't support multi view or split views on iPad, but seems this feature is enabled by default to any new project in Xcode, how to disable it ?
Kind Regards
Topic:
UI Frameworks
SubTopic:
General
I have a popover/sheet in iOS which allows users to search and add items to a list. When the sheet is shown, the search should always be active.
I am using searchable on a NavigationStack inside the sheet. I am using the isPresented parameter to activate search.
My issue is with the animation of the search activation. Even if I use...
isPresented: .constant(true)
...the search isn't activated until the sheet has completed it's entrance animation, resulting in two stages of animation.
I can't add a video here, but the two images below show the steps I am seeing. First a slide up animation, with the search in the navigation drawer, then a second animation, once the sheet is fully in place, as the search becomes active.
Is it possible to merge these two animations, so search is in place when the sheet animates up?
Topic:
UI Frameworks
SubTopic:
SwiftUI
I released an app for iPhone (and it's could be downloaded for iPad also), and now I developered another app for iPad version with the same code and logic but I modified the layout to fit bigger screen and make better user experience and appearance.
Howevert the app review rejected my release due to the duplicate content, how can I solve it?
Topic:
UI Frameworks
SubTopic:
General
Hello, I have encountered a question that I hope to receive an answer to. Currently, I am working on a music project for Mac Catalyst and need to enable music files such as FLAC to be opened by right clicking to view my Mac Catalyst app. But currently, I have encountered a problem where I can see my app option in the right-click open mode after debugging the newly created macOS project using the following configuration. But when I created an iOS project and converted it to a Mac Catalyst app, and then modified the info.plist with the same configuration, I couldn't see my app in the open mode after debugging. May I ask how to solve this problem? Do I need to configure any permissions or features in the Mac Catalyst project? I have been searching for a long time but have not found a solution regarding it. Please resolve it, thank you.
Here is the configuration of my macOS project:
CFBundleDocumentTypes
CFBundleTypeExtensions
flac
CFBundleTypeIconSystemGenerated
1
CFBundleTypeName
FLAC Audio File
CFBundleTypeRole
Viewer
LSHandlerRank
Default
Note: Sandbox permissions have been enabled for both the macOS project and the iOS to Mac Catalyst project. The Mac Catalyst project also has additional permissions for com. apple. security. files. user taught. read write
Anyone know how to reduce the padding between list section header (plain style) and search bar? I have tried all available method on google but none work. The default list style does not have this big padding/space between the section header and the search bar.
struct Demo: View {
@State private var searchText: String = ""
var body: some View {
NavigationStack {
List {
Section {
ForEach(0..<100) { index in
Text("Sample value for \(index)")
}
} header: {
Text("Header")
.font(.headline)
}
}
.listStyle(.plain)
.navigationTitle("Demo")
.navigationBarTitleDisplayMode(.inline)
.searchable(text: $searchText)
}
}
}
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Button ("Button 1") {
print ("Button 1");
}
.keyboardShortcut("k", modifiers: .command)
Button ("Button 2") {
print ("Button 2");
}
.keyboardShortcut("k", modifiers: .command)
}
}
}
I the above snippet, I have assigned the same keyboard shortcut (cmd +k) to 2 different buttons. According to the docs, if multiple controls are associated with the same shortcut, the first one found is used.
How do I figure out if Button 1 would be found first during the traversal or Button 2 ?
Is it based on the order of declaration? Is it always the case that Button 1 would be found first since it was declared before Button 2 ?
I'm using UIDocumentBrowserViewController. This view controller automatically creates a TabView with navigation titles and up to two trailing navigation bar items.
To visualize this, open the Files app by Apple on an iPhone.
I want to do the following:
Add a third button and place it farthest on the trailing side.
Keep all three buttons blue (the default color), but adjust the color of the navigation title to use the primary text color (it is also currently blue, by default)
Button Order
If my button is represented by C, then the order from left-to-right or leading-to-trailing should be A B C.
I tried to add it by using additionaltrailingnavigationbarbuttonitems:
class DocumentBrowserViewController: UIDocumentBrowserViewController, UIDocumentBrowserViewControllerDelegate
{
override func viewDidLoad()
{
super.viewDidLoad()
let button = UIBarButtonItem(...)
additionalTrailingNavigationBarButtonItems.append(button)
}
}
This always adds it as the leftmost trailing item. The order when the view loads is C A B, where C represents my button.
Here are some things I've tried:
Add it in viewWillAppear - same results.
Add it in viewDidAppear - same results.
Add it using rightBarButtonItems - does not show up at all.
insert it at: 0 instead of appending it - same results.
Add it with a delay using DispatchQueue.main.async - same results.
After some experimentation, I realized that the arrays referenced by additionalTrailingNavigationBarButtons and rightBarButtonItems seem to be empty, other than my own button. This is the case even if the DispatchQueue delay is so long that the view has already rendered and the two default buttons are clearly visible. So I'm not sure how to place my button relative to these, since I can't figure out where they actually are in the view controller's properties.
How do I put my button farther to the trailing/right side of these two default buttons?
Title Color
The navigation titles created by UIDocumentBrowserViewController are blue when not in their inline format. I want them to use the primary text color instead.
In viewDidLoad, I could do something like this:
UINavigationBar.appearance().tintColor = UIColor.label
This will change the title color to white or black, but it will also change the color of the buttons. I've tried various approaches like titleTextAttributes, and none of them seem to work with this view controller.
How do I change just the color of the navigation title, and not the color of the navigation bar items?
Topic:
UI Frameworks
SubTopic:
UIKit
I have a custom keypad to accept numeric input for iPads that I have been using for many years now. This is longstanding working code. With iOS 18 the touchUpInside (and other) events in the underlying Objective-C modules are not called in the file owner module when activated from the interface. The buttons seem to be properly activated based on the visual cues (they change colors when pressed). This is occurring in both simulators and on hardware. Setting the target OS version does not help. What could the cause and/or solution of this be?
App update in which there were no changes regarding the widget. Just after it updated, the widget turns black in some cases. It also appears black in the widget gallery. Removing and adding it again did not work in this case, only after an iOS restart it works fine again
This is the log
2025-03-20 02:14:05.961611 +0800 Content load failed: unable to find or unarchive file for key: [com.aa.bb::com.aa.bb.widget:cc_widget:systemMedium::360.00/169.00/23.00:(null)~(null)] on no host. The session may still produce one shortly. Error: Using url file:///private/var/mobile/Containers/Data/PluginKitPlugin/51C5E4F2-6F1F-4466-A428-73C73B9CC887/SystemData/com.apple.chrono/placeholders/cc_widget/systemMedium----360.00w--169.00h--23.00r--1f--0.00t-0.00l-0.00b0.00t.chrono-timeline ... Error Domain=NSCocoaErrorDomain Code=4 "file“systemMedium----360.00w--169.00h--23.00r--1f--0.00t-0.00l-0.00b0.00t.chrono-timeline”not exist。" UserInfo={NSFilePath=/private/var/mobile/Containers/Data/PluginKitPlugin/51C5E4F2-6F1F-4466-A428-73C73B9CC887/SystemData/com.apple.chrono/placeholders/cc_widget/systemMedium----360.00w--169.00h--23.00r--1f--0.00t-0.00l-0.00b0.00t.chrono-timeline, NSUnderlyingError=0xa693d3a80 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
My assumption has always been that [NSApp runModalForWindow:] runs a modal window in NSModalPanelRunLoopMode.
However, while -[NSApplication _doModalLoop:peek:] seems to use NSModalPanelRunLoopMode when pulling out the next event to process via nextEventMatchingMask:untilDate:inMode:dequeue:, the current runloop doesn't seem to be running in that mode, so during -[NSApplication(NSEventRouting) sendEvent:] of the modal-specific event, NSRunLoop.currentRunLoop.currentMode returns kCFRunLoopDefaultMode.
From what I can tell, this means that any event processing code that e.g. uses [NSTimer addTimer:forMode:] based on the current mode will register a timer that will not fire until the modal session ends.
Is this a bug? Or if not, is the correct way to run a modal session something like this?
[NSRunLoop.currentRunLoop performInModes:@[NSModalPanelRunLoopMode] block:^{
[NSApp runModalForWindow:window];
}];
[NSRunLoop.currentRunLoop limitDateForMode:NSModalPanelRunLoopMode];
Alternatively, if the mode of the runloop should stay the same, I've seen suggestions to run modal sessions like this:
NSModalSession session = [NSApp beginModalSessionForWindow:theWindow];
for (;;) {
if ([NSApp runModalSession:session] != NSModalResponseContinue)
break;
[NSRunLoop.currentRunLoop limitDateForMode:NSModalPanelRunLoopMode];
}
[NSApp endModalSession:session];
Which would work around the fact that the timer/callbacks were scheduled in the "wrong" mode. But running NSModalPanelRunLoopMode during a modal session seems a bit scary. Won't that potentially break the modality?