We have a IOS app and we are using the same app for Mac Catalyst.
In IOS we are able to detect when user take the screenshot using UIApplicationUserDidTakeScreenshotNotification. But in MACCatalyst it is not working.
As per docs UIApplicationUserDidTakeScreenshotNotification and UIScreenCapturedDidChangeNotification are both supported for MacCatalyst 13.1+. But I am not getting screen shot notifications using both
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
As can be seen in the screenshot attached, I can not see the options in this window. A prompt window before this also did not show any buttons in the visible space. However, I made a guess and could get to this window by clicking on what I think was "Ok" or something similar.
But on this I could not do any action and had to force quit the app.
Hi, I am having some troubles creating a "nested" RealityView content using MapKit attachment.
I am building a visionOS app that has horizontal MapKit map as an attachment to RealityView. I want to display 3D pins on that map, therefore I am using native map annotation and inside of these annotations, I create a new RealityView just for the 3D pin. This worked completely fine, unitil I wanted to have those RealityViews interact with each other.
By interaction of those RealityViews I mean that I wanted to group entities from the first "main" RealityViews content with the 3D pins using ModelSortGroupComponent.
Why I want this? I want to make the map circular, that is not a problem. Problem is that when I move the map with 3D pins, these pins have their own RealityView space and are only bounded by volumetric window dimensions. What happes is that these pins float next to the map (shown on attached image). So I came up with this solution: create a custom "toroid" like 3D entity model that occludes the pins that go outside the map region. In order to occlude only the pins, I need to use ModelSortGroupComponent to group the "toroid" entity with 3D pins entities (as described in another forum thread).
To summarize: need the content of the superior RealityView to interact with map attachment annotations RealityView content in order to group them. There might be of course another, better way to achieve my whole goal, so I would naturally appreciate any help or guidance.
Image below showing 3D pins on circular map. Since pins RealityView does no know anything about other RealityViews, it just overlows and hangs in space until is cropped by volumetric window boundary.
Simplified code:
var body: some View {
let modelSortGroup = ModelSortGroup(depthPass: .prePass)
RealityView { content, attachments in
var mainEntity = Entity()
// My other entities here...
if let mapAttachment = attachments.entity(for: "mapAttachment") {
// Edit map properties, position, horizontal layout etc.
mainEntity.addChild(mapAttachment)
}
// Create and add to content mask "toroid" entity mapMaskEntity. Use OcclusionMaterial() material.
mapMaskEntity.components.set(ModelSortGroupComponent(group: modelSortGroup, order: 0))
// For all pins, somehow also set the group
// 3DPinEntity.components.set(ModelSortGroupComponent(group: modelSortGroup, order: 1))
content.add(mainEntity)
} attachments: {
Attachment(id: "mapAttachment") {
Map {
ForEach(mapViewModel.clusters, id: \.id) { cluster in
Annotation("", coordinate: cluster.coordinate) {
MapPin3DView(cluster: cluster)
}
}
}
.clipShape(Circle())
}
}
}
// MapPin3DView is an map annotation view that includes a model of 3D pin and some details like image etc., uses RealityView.
struct MapPin3DView: View {
var body: some View {
RealityView { content in
// 3D pin entities...
}
}
}
Not sure what could cause this. the UI align differently running on iPhone versus running on Mac. If I remove the HStack, it works but I still would like to know why, and if there is a way to make it right on both platforms.
Thank you
here is my code
@State private var viewModel = FirmwareSelectionViewModel()
var body: some View {
Form {
Section("Setup Name") {
TextField ( "", text: $viewModel.setupName )
.foregroundColor(.green )
.disableAutocorrection(true)
.onSubmit {
print ("On Submit")
}
}
Section("Battery") {
HStack() {
Text("Volt")
TextField("", value: $viewModel.Vnominal, format: .number)
.textFieldStyle(.roundedBorder)
.foregroundColor(.green )
#if !os(macOS)
.keyboardType(.decimalPad)
#endif
.onChange(of: viewModel.Vnominal) {
viewModel.checkEntryValidity()
print("Updated Vnominal: \(viewModel.Vnominal)")
}
Text("Ah")
TextField("", value: $viewModel.batteryCapacity, format: .number)
.textFieldStyle(.roundedBorder)
.foregroundColor(.green )
#if !os(macOS)
.keyboardType(.decimalPad)
#endif
.onChange(of: viewModel.batteryCapacity) {
viewModel.checkEntryValidity()
print("Updated Battery Capacity: \(viewModel.batteryCapacity)")
}
}
}
Section("Firmware Type") {
Picker(selection: $viewModel.selectedType, label: EmptyView()) {
ForEach(TypeOfFirmware.allCases) { type in
Text(type.rawValue).tag(type as TypeOfFirmware)
.foregroundColor(.green )
}
}
.pickerStyle(SegmentedPickerStyle())
Picker(selection: $viewModel.selectedFirmware, label: EmptyView()) {
ForEach(viewModel.availableFirmware) { firmware in
Text(firmware.rawValue.capitalized).tag(firmware as Firmware)
}
}
.pickerStyle(SegmentedPickerStyle())
}
}
.onChange(of: viewModel.selectedType) {
viewModel.resetFirmwareSelection()
}
.navigationTitle("Firmware Selection")
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
I'm working on a SwiftUI based application for MacOS. I have a TabView component with two child Tab components. These Tab components display a List, each derived from an array of elements.
While the application is running, clicking on the tabs in the TabView should switch between the views of different Lists. What I'm experiencing is that switching between the tabs causes a FAULT. With errors:
Row index 1 out of row range (numberOfRows: 1) for <SwiftUI.SwiftUIOutlineListView: 0x1299d2000>
Followed by:
(
0 CoreFoundation 0x000000019e096e80 __exceptionPreprocess + 176
1 libobjc.A.dylib 0x000000019db7ecd8 objc_exception_throw + 88
2 AppKit 0x00000001a1c744e8 -[NSTableRowData _availableRowViewWhileUpdatingAtRow:] + 0
3 SwiftUI 0x00000001cd8953f4 $s7SwiftUI0A17UIOutlineListViewC11removeItems2at8inParent13withAnimationy10Foundation8IndexSetV_ypSgSo07NSTableeL7OptionsVtF + 1232
...
...
)
And finally:
FAULT: NSTableViewException: Row index 1 out of row range (numberOfRows: 1) for <SwiftUI.SwiftUIOutlineListView: 0x1299d2000>; (user info absent)
This error happens when switching between the two tabs, defined thusly:
@main
struct MyApp: App {
@State var rootDirectory: URL
@State var selectedItem: URL
@State var projectNavItems: [NavigationItem] = []
@State var jotNavItems: [NavigationItem] = []
@State var importerIsPresented: Bool = false
let fileManager = FileManager.default
init() {
rootDirectory = URL(string: FileManager.default.currentDirectoryPath)!
selectedItem = URL(string: FileManager.default.currentDirectoryPath)!.appendingPathComponent("README.md")
}
var body: some Scene {
WindowGroup {
NavigationSplitView {
TabView {
Tab("Projects", systemImage: "tray.and.arrow.down.fill") {
List(projectNavItems, selection: $selectedItem) {
// Changing this NavigationLink line to Text($0.title) makes no difference
NavigationLink($0.title, value: $0.id)
}
}
Tab("Jots", systemImage: "tray.and.arrow.up.fill") {
List(jotNavItems, selection: $selectedJot) {
// Can be written as Text($0.title) with no change in behavior
NavigationLink($0.title, value: $0.id)
}
}
}
} detail: {
Editor(for: selectedItem)
}
.fileImporter(
isPresented: $importerIsPresented,
allowedContentTypes: [UTType.folder],
allowsMultipleSelection: false
) { result in
// Code that gets a security scoped resource and populates the
// projectNavItems: [NavItem] and jotNavItems: [NavItem]
// arrays
}
}
.commands(content: {
CommandGroup (before: .newItem) {
Button("Open Journal...") {
importerIsPresented.toggle()
}
}
})
}
}
The error only happens when both Tab views are populated by a List. If the Tab view have different child components, say a List, and a ForEach of Text components, switching between the tabs doesn't produce this error. List views with Text child components also produce this error.
Here are screenshots of the running application
Once the user selects a directory, we see the first Tab > List component populated by contents from the projectNavItems array:
Clicking on the 'Jots' tab switches to the appropriate tab and correctly lists the items in the jotNavItems array, except there are additional lines, seemingly showing that there's an issue.
Clicking back on the 'Projects' tab switches back, but now the List shows only one of the items from the projectNavItems array.
Finally, clicking on 'Jots' again causes the errors to print in the console and interactivity with the tab components ceases. Last screenshot is representative of this state as the application FAULTS.
This seems like a bug in SwifUI, wondering what workarounds I might be able to implement.
I can provide the full backtrace, I cropped it for content length.
Working on a MacOS SwiftUI app - recently, when the app stays running from the night before, it no longer responds to keystrokes - data entry, or cursor navigation keys.
It does respond to mouse activity and clicks ... very weird.
Hi team. I am working on an app that uses the Screen Time API. I got access to the family controls (distribution) capability through the request process for my main app. I added a DeviceActivityReport extension in XCode, but haven't been able to get the extension to show up on the screen. I noticed that the extension only has the development version of the family controls capability available. Is this the source of my errors? I was able to get the screen time displayed in a test app I built where both the main app and extension used the development version of the capability, which led me to believe that discrepancy could be the issue.
Let me know if there is anything I can provide to help in the debugging process. I didn't send a minimal example in this request due to the fact that I would have to remove most of my functionality to create a "minimal" example (since the signing is only for my main app), but I can do that if needed. Thanks! I looked through the logs in the console for the phone (I'm testing on a real iPhone 13 Pro Max), but didn't see anything that popped out after looking (not exactly sure what to look for though).
STEPS TO REPRODUCE:
Create an app with the Family Controls, Distribution capability. Then create the DeviceActivityReport with the Family Control, Development capability. Attempt to see the DeviceActivityReport in the main app.
NOTE: I was successfully able to create a minimal test app completely separately that used the Development versions of the capabilities for both with the exact same extension code. That's why I think the issue could be due to the capability version discrepancy.
Hi,
I have the following swiftUI code:
Image(uiImage: image)
.resizable()
.aspectRatio(contentMode: .fit)
.colorEffect(ShaderLibrary.AlphaConvert())
and the following shader:
[[ stitchable ]] half4 AlphaConvert(float2 position, half4 currentColor) {
return half4(currentColor.r>0.5,currentColor.r<=0.5,0,(currentColor.r>0.5));
}
I am loading a full-res image from my photo library (24MP)... The image initially displays fine, with portions of the image red, and the rest black (due to alpha blending)... However, after rotating the device, I get an image that is a combination of red&green... Note, that the green pixels from the shader have alpha 0, hence, should never be seen. Is there something special that needs to be done on orientation changes so that the shader works fine?
I am creating an application that uses VNDetectBarcodesRequest to read QR codes from images and adjust the image orientation to match that of the QR code finder pattern.
The QR code was successfully read, and the coordinates of the QR code were obtained.Upon checking the obtained topLeft, topRight, and bottomLeft coordinates, they always seem to match the topLeft, topRight, and bottomLeft coordinates of the finder pattern.
Is it specified that the coordinates of topLeft, topRight, and bottomLeft obtained with VNDetectBarcodesRequest match the topLeft, topRight, and bottomLeft of the finder pattern? Or do they just happen to match?
I would appreciate it if you could tell me if the matching of coordinates is a specification.
Thank you for your help.
I'm pretty new to Swift and SwiftUI. I'm making my first app for sorting a gallery with some extra features.
I was using my own iPhone for testing and just started testing my app on other Apple products.
Everything works fine on iPad Air M1, iPhone 15 Pro, iPhone 15 Pro Max, iPhone 13, iPhone XS (Simulator), and iPhone 11 Pro (Simulator). However, when I tried to show my app to a family member with an iPhone 11, I came across an issue.
Issue Description:
My app takes all photos from iPhone's native gallery, then you can sort it by some spesific filters and delete pictures. It just looks like the native gallery. (I can add photos later if needed) You can just scroll the gallery by swiping up and down. You can press the select button and start selecting pictures to delete.
I recently added a drag-to-select-multiple-pictures feature. This makes it feel more like the native iOS experience, eliminating the need to tap each picture individually.
However, on the iPhone 11, the moment you open the app, you can't scroll. Scrolling is completely locked. You can still select pictures by tapping or dragging, so it's not a touch area issue. The same issue persists on the iPhone 11 simulator.
And I think I found the problematic part in my (sadly messy) ContentView.swift file;
ScrollView {
RefreshControl(coordinateSpace: .named("refresh")) {
await viewModel.refreshMediaItems()
}
LazyVGrid(columns: gridColumns, spacing: UIDevice.current.userInterfaceIdiom == .pad ? 12 : 4) {
let items = viewModel.filteredItems(typeFilter: mediaTypeFilter, specialFilter: specialFilter)
ForEach(Array(zip(items.indices, items)), id: \.1.id) { index, item in
MediaThumbnailView(
item: item,
isSelected: selectedItems.contains(item.id),
viewModel: viewModel,
onLongPress: {
if !isSelectionMode {
toggleSelectionMode()
selectedItems.insert(item.id)
}
},
onTap: {
if isSelectionMode {
toggleSelection(item: item)
} else {
viewModel.selectItem(item)
}
}
)
.aspectRatio(1, contentMode: .fit)
.background(
GeometryReader { geometry in
let frame = geometry.frame(in: .named("grid"))
Color.clear.preference(
key: ItemBoundsPreferenceKey.self,
value: [ItemBounds(id: item.id, bounds: frame, index: index)]
)
}
)
}
}
.padding(.horizontal, 2)
.coordinateSpace(name: "grid")
.onPreferenceChange(ItemBoundsPreferenceKey.self) { bounds in
itemBounds = Dictionary(uniqueKeysWithValues: bounds.map { ($0.id, $0) })
itemIndices = Dictionary(uniqueKeysWithValues: bounds.map { ($0.id, $0.index) })
}
.gesture(
DragGesture(minimumDistance: 0)
.onChanged { gesture in
if isSelectionMode {
let location = gesture.location
if !isDragging {
startDragging(at: location, in: itemBounds)
}
updateSelection(at: location, in: itemBounds)
}
}
.onEnded { _ in
endDragging()
}
)
}
.coordinateSpace(name: "refresh")
}
you can see the .gesture(.... part. I realised that this DragGesture and ScrollView blocks each other (somehow only on iPhone 11)
highPriorityGesture also won't work.
When I change it with simultaneousGesture, scroll starts to work again.
BUT - since it's simultaneous, when multiple selection mode is activated, when I'm dragging my finger gallery also starts to scroll and it becomes a very unpleasant experience. After this issue I realised on native gallery iOS locks scroll when you are dragging for multiple selection and just when you release your finger you can scroll again even if the multiple selection mode is active.
I tried a million things, asked claude, chatgpt etc. etc.
Found some similar issues on stackoverflow but they were all related to iOS 18, not spesific to an iPhone. My app works fine on iOS 18 (15 Pro Max)
iOS 18 drag gesture blocks scrollview
Here are the some of the things I've tried: using highPriorityGesture and simultenousgesture together, tried to lock the scroll briefly while dragging, implement much complicated versions of these things with the help of claude, try to check if isSelectionMode is true or not
All of them broke other things/won't work.
Probably there's something pretty simple that I'm just missing; but iPhone 11 being the single problematic device confuses me. I don't want to mess too much with my already fragile logic.
My app uses UIDocumentPickerViewController to display image files that are saved on iCloud Drive.
In previous versions of iOS the user could long press on an image file and an option to Delete was shown. This no longer seems to be the case in iOS 18.
Is there a way to allow users to delete files when using a UIDocumentPickerViewController?
Xcode 16.2 (16C5032a)
FB16300857
Consider the following SwiftData model objects (only the relevant portions are shown) (note that all relationships are optional because eventually this app will use CloudKit):
@Model
final public class Team {
public var animal: Animal?
public var handlers: [Handler]?
...
}
@Model
final public class Animal {
public var callName: String
public var familyName: String
@Relationship(inverse: \Team.animal) public var teams: [Team]?
...
}
@Model
final public class Handler {
public var givenName: String
@Relationship(inverse: \Team.handlers) public var teams: [Team]?
}
Now I want to display Team records in a list view, sorted by animal.familyName, animal.callName, and handlers.first.givenName.
The following code crashes:
struct TeamListView: View {
@Query<Team>(sort: [SortDescriptor(\Team.animal?.familyName),
SortDescriptor(\Team.animal?.callName),
SortDescriptor(\Team.handlers?.first?.givenName)]) var teams : [Team]
var body: some View {
List {
ForEach(teams) { team in
...
}
}
}
}
However, if I remove the sort clause from the @Query and do the sort explicitly, the code appears to work (at least in preliminary testing):
struct TeamListView: View {
@Query<Team> var teams: [Team]
var body: some View {
let sortedTeams = sortResults()
List {
ForEach(sortedTeams) { team in
...
}
}
}
private func sortResults() -> [Team] {
let results: [Team] = teams.sorted { team1, team2 in
let fam1 = team1.animal?.familyName ?? ""
let fam2 = team2.animal?.familyName ?? ""
let comp1 = fam1.localizedCaseInsensitiveCompare(fam2)
if comp1 == .orderedAscending { return true }
if comp1 == .orderedDescending { return false }
... <proceed to callName and (if necessary) handler givenName comparisons> ...
}
}
}
While I obviously have a workaround, this is (in my mind) a serious weakness in the implementation of the Query macro.
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 want to have my own background and foreground colors for some views and I am having a bit of trouble. I cannot figure out how to remove the margins around some built-in views. One example is below. The ScrollView portion is always black or white, depending on whether I am I dark mode or not. I've added various colors and borders to see what is going on below. I've also tried adding the modifiers to the Scroll View rather than the TextEditor and it doesn't work at all. If I don't have the .frame modifier on the ScrollView, the TextEditor moves to the top of its frame for some reason. I've played with .contentMargins, .edgeInsets, etc. with no luck
How do I get the TextEditor to fill the entire ScrollView without the margin? Thanks!
import SwiftUI
struct TextEditorView: View
{ @Binding var editString: String
var numberOfLines: Int
var lineHeight: CGFloat
{ UIFont.preferredFont(forTextStyle: .body).lineHeight
}
var viewHeight: CGFloat
{ lineHeight * CGFloat(numberOfLines) + 8
}
var body: some View
{ ScrollView([.vertical], showsIndicators: true)
{ TextEditor(text: $editString)
.border(Color.red, width: 5)
.foregroundStyle(.yellow)
.background(.blue)
.frame(minHeight:viewHeight, maxHeight: viewHeight)
.scrollContentBackground(.hidden)
}
.frame(minHeight:viewHeight, maxHeight: viewHeight)
}
}
According to the MVVM design pattern, one of my views depends on many properties in my model. Can I use logic like @published var model = MyModel()? Will there be a large performance loss? Will the UI be refreshed when other unrelated properties in the model are modified? What is the best practice in this case?
Topic:
UI Frameworks
SubTopic:
General
My App always encounter with CoreAutoLayout invade
My SnapKit layout constraint as follow:
popBgView.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.leading.equalTo(assistantTeacherView.snp.trailing).offset(.isiPad ? -50 : -40)
if TTLGlobalConstants.isCompactScreen320 {
make.width.lessThanOrEqualTo(300)
} else {
let widthRatio = .isiPad ? 494.0 / 1024.0 : 434.0 / 812.0
make.width.lessThanOrEqualTo(TTLGlobalConstants.screenWidth * widthRatio)
}
bubbleViewRightConstraint = make.trailing.equalToSuperview().constraint
}
.....
popBgView.addSubview(functionView)
msgLabel.snp.remakeConstraints { make in
make.leading.equalToSuperview().inset(Metric.msgLabelHorizantalInset)
make.centerY.equalToSuperview()
make.trailing.lessThanOrEqualToSuperview().inset(Metric.msgLabelHorizantalInset)
make.top.equalTo(Metric.msgLabelVerticalInset)
}
functionView.snp.makeConstraints { make in
make.leading.equalTo(msgLabel.snp.trailing).offset(Metric.msgLabelFunctionSpacing)
make.centerY.equalToSuperview()
make.trailing.equalToSuperview().offset(-Metric.msgLabelHorizantalInset)
}
msgLabel and functionView superview is popBgView
However, when I try remove from superview for functionView, There is low probability crash:
OS Version: iOS 16.1.1 (20B101)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: SEGV_NOOP
Crashed Thread: 0
Application Specific Information:
Exception 1, Code 1, Subcode 14967683541490370463 >
KERN_INVALID_ADDRESS at 0xcfb7e4e0f8fe879f.
Thread 0 Crashed:
0 CoreAutoLayout 0x382555f44 -[NSISEngine positiveErrorVarForBrokenConstraintWithMarker:errorVar:]
1 CoreAutoLayout 0x382555e9c -[NSISEngine positiveErrorVarForBrokenConstraintWithMarker:errorVar:]
2 CoreAutoLayout 0x3825557e4 -[NSISEngine removeConstraintWithMarker:]
3 CoreAutoLayout 0x382555198 -[NSLayoutConstraint _removeFromEngine:]
4 UIKitCore 0x34d87961c __57-[UIView _switchToLayoutEngine:]_block_invoke
5 CoreAutoLayout 0x382556e8c -[NSISEngine withBehaviors:performModifications:]
6 UIKitCore 0x34d8a1c38 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]
7 UIKitCore 0x34d7f01b0 __57-[UIView _switchToLayoutEngine:]_block_invoke_2
8 UIKitCore 0x34d879770 __57-[UIView _switchToLayoutEngine:]_block_invoke
9 CoreAutoLayout 0x382556e8c -[NSISEngine withBehaviors:performModifications:]
10 UIKitCore 0x34d8a1c38 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]
11 UIKitCore 0x34d8a1848 __45-[UIView _postMovedFromSuperview:]_block_invoke
12 UIKitCore 0x34e7ff8d0 -[UIView _postMovedFromSuperview:]
13 UIKitCore 0x34d85e3c8 __UIViewWasRemovedFromSuperview
14 UIKitCore 0x34d85b1a4 -[UIView(Hierarchy) removeFromSuperview]
15 Collie-iPad 0x203001550 [inlined] InClassAssistantView.functionView.didset (InClassAssistantView.swift:105)
Topic:
UI Frameworks
SubTopic:
UIKit
We are using the contactAccessPicker modifier connected to a Button to allow the user to change the selection of contacts that he allows for use in our app. In the two places where the iOS UI screen refers to our app:
"manage which contacts can access." on top,
and below in the explanatory text, again ,
the value of is taken probably from the app's PRODUCT_NAME. Instead, we need it to be either CFBundleName or CFDisplayBundleName.
In our case they are different (PRODUCT_NAME is legacy, reasons of rebranding, which is a very common reason in apps).
Is there a specific reason why iOS is using PRODUCT_NAME (or something similar) in the contactAccessPicker UI screen instead of the user facing CFBundleName or CFDisplayBundleName? or is this a bug?
Topic:
UI Frameworks
SubTopic:
SwiftUI
I recently detected a special crash on 18.0, 18.1, 18.1.1, 18.2,18.3 which cannot be repeated, and the page logs are related to the keyboard, is there any idea to deal with this problem?
Exception Category: nsexception
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000 at 0x0000000000000000
Crashed Thread: 0
CrashDoctor Diagnosis: Application threw exception NSInternalInconsistencyException: Multi layer delegate table missing.
Thread 0 Crashed:
0 CoreFoundation 0x00000001869d87cc __exceptionPreprocess + [ : 164]
1 libobjc.A.dylib 0x0000000183cab2e4 objc_exception_throw + [ : 88]
2 Foundation 0x0000000185da88d8 _userInfoForFileAndLine
3 UIKitCore 0x0000000189e78074 -[UIView _multiLayerDelegatesTableCreateIfNecessary:] + [ : 208]
4 UIKitCore 0x0000000189e780c4 -[UIView _registerMultiLayerDelegate:] + [ : 36]
5 UIKitCore 0x00000001894874c0 -[_UIPortalView setSourceView:] + [ : 132]
6 UIKitCore 0x000000018a1eb6bc -[_UIPortalView initWithSourceView:] + [ : 68]
7 UIKitCore 0x000000018a213ea4 -[_UITextMagnifiedLoupeView initWithSourceView:] + [ : 444]
8 UIKitCore 0x000000018a6c461c +[UITextLoupeSession _makeLoupeViewForSourceView:selectionWidget:orientation:] + [ : 84]
9 UIKitCore 0x000000018a6c47bc +[UITextLoupeSession _beginLoupeSessionAtPoint:fromSelectionWidgetView:inView:orientation:] + [ : 304]
10 UIKitCore 0x0000000189d50ce0 -[UITextRefinementTouchBehavior textLoupeInteraction:gestureChangedWithState:location:translation:velocity:modifierFlags:shouldCancel:] + [ : 1756]
11 UIKit 0x0000000240e309e0 -[UITextRefinementTouchBehaviorAccessibility textLoupeInteraction:gestureChangedWithState:location:translation:velocity:modifierFlags:shouldCancel:] + [ : 216]
12 UIKitCore 0x000000018a4d45b4 -[UITextRefinementInteraction loupeGestureWithState:location:translation:velocity:modifierFlags:shouldCancel:] + [ : 124]
13 UIKitCore 0x000000018a4d3f74 -[UITextRefinementInteraction loupeGesture:] + [ : 548]
14 UIKitCore 0x000000018952eac4 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + [ : 128]
15 UIKitCore 0x000000018952e934 _UIGestureRecognizerSendTargetActions + [ : 92]
16 UIKitCore 0x000000018952e6f4 _UIGestureRecognizerSendActions + [ : 284]
17 UIKitCore 0x00000001891e1b28 -[UIGestureRecognizer _updateGestureForActiveEvents] + [ : 572]
18 UIKitCore 0x00000001891b3724 _UIGestureEnvironmentUpdate + [ : 2488]
19 CoreFoundation 0x000000018697a1f4 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + [ : 36]
20 CoreFoundation 0x0000000186979f98 __CFRunLoopDoObservers + [ : 552]
21 CoreFoundation 0x00000001869a9028 __CFRunLoopRun + [ : 948]
22 CoreFoundation 0x00000001869a8830 CFRunLoopRunSpecific + [ : 588]
23 GraphicsServices 0x00000001d29881c4 GSEventRunModal + [ : 164]
24 UIKitCore 0x000000018950eeb0 -[UIApplication _run] + [ : 816]
25 UIKitCore 0x00000001895bd5b4 UIApplicationMain + [ : 340]
26 顺丰小哥 0x0000000104423cc0 main + [main.m : 13]
27 (null) 0x00000001ac396ec8 0x0 + 7184412360
Topic:
UI Frameworks
SubTopic:
UIKit
private let datePicker = {
let picker = UIDatePicker()
picker.backgroundColor = .clear
picker.datePickerMode = .dateAndTime
picker.preferredDatePickerStyle = .compact
return picker
}()
UITabBarController
|
|
VC_Tab1 --------------------------- VC_Tab2
| |
| |
VC_Tab1_Child VC_Tab2_Child
|
(HeaderView)
|
(MyButton)
The structure of the view controllers and views in the project is as described above.
<case 1>
self.navigationController?.popToRootViewController(animated: false)
tabBarController.selectedIndex = 1
When popToRootViewController(animated: false) is called in VC_Tab1_Child, followed by setting the tab controller’s selectedIndex = 1, the following results are observed:
viewWillAppear(_:), <VC_Tab2_Child>
deinit, <VC_Tab1_Child>
viewDidAppear(_:), <VC_Tab2_Child>
The originally expected results are as follows
viewWillDisappear(_:), <VC_Tab1_Child>
viewDidDisappear(_:), <VC_Tab1_Child>
deinit, <VC_Tab1_Child>
deinit, <HeaderView>
deinit, <MyButton>
headerView.backButton.rx.tap -> Event completed
headerView.backButton.rx.tap -> isDisposed
viewWillAppear(_:), <VC_Tab2_Child>
viewDidAppear(_:), <VC_Tab2_Child>
The HeaderView belonging to VC_Tab1_Child was not deallocated, and the resources associated with that view were also not released. Similarly, VC_Tab1_Child.viewWillDisappear and VC_Tab1_Child.didDisappear were not called.
<case 2>
self.navigationController?.popToRootViewController(animated: false)
DispatchQueue.main.async {
tabBarController.selectedIndex = 1
}
After performing the pop operation as shown in the code and waiting for a short period before testing, the expected results were generally achieved. (However, rarely, the results were similar to those observed when called without async.)”
<case 3>
self.navigationController?.popToRootViewController(animated: false)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
tabBarController.selectedIndex = 1
}
When a sufficient delay was ensured as described above, the expected results were achieved 100% of the time.”
The abnormal behavior is more pronounced in iOS versions prior to 18 and varies depending on the iOS version.
I couldn’t find any documentation explaining the unexpected behavior shown in the results above. What could be the cause? The simulation code is provided below.
https://github.com/linusix/UITabBarController_Test2