Post

Replies

Boosts

Views

Activity

List row stay selected after back
Hi, I found a case that cause a list to never deselect the row when the back button is pressed. In the following code I modally present a list. When you select a row another list is displayed. If you select a row of the second list and you go back the row will stay selected. This is the code: struct ContentView: View { 		@State var modalVisible = false 		var body: some View { 				Button(action:{ 						self.modalVisible.toggle() 				}) { 						Text("Open modal") 				} 				.sheet(isPresented: $modalVisible) { 						NavigationView { 								List { 										NavigationLink("Item", destination: List { 												NavigationLink("Sub Item", destination: Text("If you go back the row will stay selected.")) 										})                 }             }         }     } } Does anyone know if there is a way to force the list to deselect the row when the back button is pressed? Thank you
2
0
2.2k
Mar ’21
UITabBarController is unsupported as viewController
Hi, I'm testing one of my app on iOS 14 with Xcode 12 beta 3 (12A8169g) and I have a problem with my storyboards. Xcode give me this error for all the storyboards that contain a split view controller: An internal error occurred. Editing functionality may be limited. The log generated by the Xcode "Report a bug" button say: Exception name: NSInvalidArgumentException Exception reason: UITabBarController is unsupported as viewController for -[UISplitViewController setViewController:forColumn:] in Primary column It worked correctly on Xcode 12 beta 2. Has anyone encountered the same problem and found a way to fix it? Thank you
7
0
2.9k
Jul ’23
Scale of image generated with MKMapSnapshotter
Hi, I need to generate the image of a map at a specific resolution. I tried to use the following code: let options = MKMapSnapshotter.Options() options.size = CGSize(width: 300, height: 200) options.scale = 1.0 options.mapRect = mapRect let mapSnapshotter = MKMapSnapshotter(options: options) if let snapshot = try? await mapSnapshotter.start() { let image = snapshot.image } Since I specified the options.scale to be 1 I expect the image resolution to be exactly 300x200 pixel (and with a scale of 1). Unfortunately the resulting image has a scale factor of 3 (on an iPhone) and the actual resolution is 900x600 pixel. I also tried, instead of using the scale option, to set the traitCollection option, like this: options.traitCollection = UITraitCollection(displayScale: 1.0) but I still get a 3x scale image with a resolution of 900x600. Why is the scale option ignored? I miss something? Thank you
1
2
1.5k
Jul ’22
Incorrect height of iPad floating keyboard
I'm using the following code to get the height of the keyboard: class ViewController: UIViewController {     override func viewDidLoad() {         super.viewDidLoad()         NotificationCenter.default.addObserver(             self,             selector: #selector(keyboardHeight),             name: UIResponder.keyboardDidChangeFrameNotification,             object: nil         )     }     @objc private func keyboardHeight(notification: Notification) {         guard let keyboardRect = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue else { return }         print("==> keyboardFrameEndUserInfoKey height: \(keyboardRect.size.height)")     } } This code on iPad work correctly when the keyboard is normal but it does not work when the keyboard is floating. After the user tap on a text field, the keyboard appear and the keyboardDidChangeFrameNotification notification is called. If the keyboard is floating then the first time we get a wrong height of 362. If the user then manually move somewhere the floating keyboard the notification is called again and the correct value of 308 is returned. It is a bug or I miss something? I need to be able to get the correct height the first time the keyboard appear. This is happening on iOS 13 and iOS 14. Any idea?
1
1
1.3k
Jul ’21
StoreKit 2 Transaction.currentEntitlements questions
Hi, I'm starting using StoreKit 2 and I have some questions regarding transactions. To check which non-consumable in-app purchases the user has purchased, immediately after starting the app I look at Transaction.currentEntitlements. That's working fine, but I have some questions about it. Question 1: What happens if the user is not connected to the internet? Will Transaction.currentEntitlements still return data? Question 2: What happens if the user sign out from the AppStore? Will Transaction.currentEntitlements be empty? Question 3: What happens if the user sign in AppStore with different credentials? Transaction.currentEntitlements will return the transaction of the new AppStore user? Thank you
0
3
872
May ’22
Popover from NSToolbarItem in Mac Catalyst app
Hi, Inside a Mac Catalyst app, I need to display a popover starting from an NSToolbarItem contained inside the app toolbar (like the Apple Maps Mac app does, see below image). In order to do that, when I press the button I need to find the toolbar item view and use it as popover anchor. How can I find the view or frame of an NSToolbarItem on Mac Catalyst? A property that could help me is the NSToolbarItem "view" property (NSView), but that property has been marked has unavailable in Mac Catalyst. Any idea? Thank you
3
3
1.9k
Feb ’24
Settings bundle with string catalog
Is it possible to use a string catalog to localize a settings bundle? Currently, to localize a Settings.bundle, we need to create a folder for each language with a single strings file inside. For example: Settings.bundle en.lproj > Root.strings fr.lproj > Root.strings de.lproj > Root.strings ... Any way to convert that to a string catalog? Thank you
2
2
2k
Jan ’24
No large titles margin on iOS 26
I need more time to adapt to the new iOS 26 UI, so I set the "UIDesignRequiresCompatibility" attribute to "Yes." This works, but now all large titles are not aligned with the content. Below you can see an example, but I have the issue with all large titles. All good on iOS 18. Does anyone have an idea why and how can i fix it?
4
2
263
Sep ’25
Diffable data source with fetched result controller on iOS 15
Hi! When using a diffable data source on iOS 13 and iOS 14 in combination with a fetched result controller, the didChangeContentWith method of the NSFetchedResultsController delegate return a new snapshot with inserted, deleted and moved items. Unfortunately, in the new snapshot items that have been modified are not refreshed. That's because the system appears to compare the identifiers to determine whether a refresh is needed or not. If we change an attribute of a Core Data entity the identifier remain the same and the item in the snapshot is not refreshed. For this reason, on iOS 13 and iOS 14, we need to manually check which objects have been updated and manually refresh the corresponding items in the snapshot. Now, it seems that on iOS 15 this is no more needed. The new snapshot I receive in the NSFetchedResultsController didChangeContentWith delegate method also contain refreshed items. So, in order to apply the new snapshot I only need to call a single line of code: func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeContentWith snapshot: NSDiffableDataSourceSnapshotReference) { guard let diffableDataSource = diffableDataSource else {return} diffableDataSource.apply(snapshot as NSDiffableDataSourceSnapshot<Section, NSManagedObjectID>, animatingDifferences: true) } That's great, but I'm not sure if that's a feature we can count on from iOS 15 onwards. Is this new behaviour documented somewhere? Thank you
4
0
2.8k
Oct ’21
MapKit crash on Catalyst after resizing the window
Hi, I am faced with a strange problem with a Catalyst app that uses MapKit. If the map is visible and I resize the window (causing the map the resize), sometime the app crashes with some Metal related error. Is this a know issue between MapKit and Catalyst? There is something I can do in order to prevent this crash? Below you can find the error message and a screenshot of the thread that caused the crash. Thank you -[MTLDebugDevice notifyExternalReferencesNonZeroOnDealloc:]:2951: failed assertion `The following Metal object is being destroyed while still required to be alive by the command buffer 0x7f96de27f600 (label: <no label set>): <MTLToolsObject: 0x7f96dde552e0> -> <BronzeMtlTexture: 0x7f96dc04c230> label = <none> textureType = MTLTextureType2D pixelFormat = MTLPixelFormatBGRA8Unorm_sRGB width = 2372 height = 1668 depth = 1 arrayLength = 1 mipmapLevelCount = 1 sampleCount = 1 cpuCacheMode = MTLCPUCacheModeDefaultCache storageMode = MTLStorageModeManaged hazardTrackingMode = MTLHazardTrackingModeTracked resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeManaged MTLResourceHazardTrackingModeTracked usage = MTLTextureUsageShaderRead MTLTextureUsageRenderTarget shareable = 0 framebufferOnly = 0 purgeableState = MTLPurgeableStateNonVolatile swizzle = [MTLTextureSwizzleRed, MTLTextureSwizzleGreen, MTLTextureSwizzleBlue, MTLTextureSwizzleAlpha] isCompressed = 0 parentTexture = <null> parentRelativeLevel = 0 parentRelativeSlice = 0 buffer = <null> bufferOffset = 0 bufferBytesPerRow = 0 iosurface = 0x0 iosurfacePlane = 0 allowGPUOptimizedContents = YES'
6
2
4.6k
Nov ’22
UITextField with isSecureTextEntry in Catalyst display an empty box
Hi, In a Mac Catalyst app, I need to allow the user insert a passcode using a UITextField. The field is used to insert a one time passcode and I want to keep the content hidden. For this reason I set the isSecureTextEntry property to true. passcodeTextField.isSecureTextEntry = true By doing this, a button to allow the user to pick a password from the keychain is displayed: This option in my case should not appear because the password is a one time password that change every time. For that reason I set the textContentType to oneTimeCode. passcodeTextField.textContentType = .oneTimeCode This actually removes the password button, but introduce something weird. If the user type something and then delete everything, a big empty box appear under the field: I have no idea what this box is and why it appears. Does anyone know why it appears and how I can remove it? Thank you
1
1
852
Apr ’25
iOS 15 prewarming and didFinishLaunchingWithOptions
Hi, Just want to understand what is the current state of iOS 15 prewarming app delegate behaviour. There is a lot of confusion (and a lack of documentation) about which app delegate methods are called during prewarming. It's not clear if didFinishLaunchingWithOptions will be called or not during prewarming. A lot of applications are counting on UserDefaults and Keychain access in didFinishLaunchingWithOptions, but sadly these two features seems to be unavailable during prewarming causing issues. Some users say that this was the case before 15.4 and that from 15.4 the didFinishLaunchingWithOptions app delegate method is no more called during prewarming. Just want to know if we can have an official statement about this. It is safe, from iOS 15.4 onwards, to use UserDefaults and access Keychain in the didFinishLaunchingWithOptions app delegate method? Thank you
2
2
3k
Sep ’23
iOS 16 UITextView line spacing when empty
Hi, I just discovered a weird bug with UITextView on iOS 16 beta 4. For some reason now, when the scrolling is disabled, the intrinsic content size of the text view is considering the line spacing even when the textview is empty. For example, in the below code we are setting a big lineSpacing of 50 to the text view typingAttributes attribute. class ViewController: UIViewController { @IBOutlet weak var textView: UITextView! { didSet { //Let's set the textView typingAttributes with a lineSpacing of 50. var attributes = [NSAttributedString.Key: Any]() let paragraphStyle: NSMutableParagraphStyle = NSMutableParagraphStyle() paragraphStyle.lineSpacing = 50 attributes[NSAttributedString.Key.paragraphStyle] = paragraphStyle attributes[NSAttributedString.Key.font] = UIFont.preferredFont(forTextStyle: .body) textView.typingAttributes = attributes } } } On previous iOS versions, everyting it's ok and the line spacing is added only when there are more than one line (see below image). However, on iOS 16 beta 4, the line spacing is added also when the content is empty (see below image on the left). A soon as we type something the height collapse to the correct height (see below image in the center). Is this a new expected behavior or a bug? If it is a bug, someone has found a temporary fix for that? Thank you
1
1
4.3k
Sep ’22
Input focus issue inside iframe
Hi!I currently developing a mobile website and found that Safari on iOS has some problems setting the focus on inputs when they are inside an iframe.When in a page you have many inputs you can tap on a field and then use the next / previous buttons on the keyboard to navigate between the fields. When the focus move to another input Safari scroll automatically the page centering the field in the page. This is great and works well.The problem is when the fields are inside a page of an iframe. In this case when you change focus from one field to another Safari has some kind of issue; the page “bounce” and the focused field is not centered in the page.I have made a video of a simple page that has this issue. In the first part of the video the page without the iframe is loaded and the focus works correctly. In the second part the page with the iframe is loaded and the issue is visible.http://www.dale1.ch/documents/safari_iframe_focus_issue.movThe code of the first page (testinput.html) where the focus is correctly handled is this:&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Test input&lt;/title&gt; &lt;meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt;&lt;span&gt;Input 1: &lt;/span&gt;&lt;input type="text" tabindex="1" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 2: &lt;/span&gt;&lt;input type="text" tabindex="2" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 3: &lt;/span&gt;&lt;input type="text" tabindex="3" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 4: &lt;/span&gt;&lt;input type="text" tabindex="4" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 5: &lt;/span&gt;&lt;input type="text" tabindex="5" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 6: &lt;/span&gt;&lt;input type="text" tabindex="6" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 7: &lt;/span&gt;&lt;input type="text" tabindex="7" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 8: &lt;/span&gt;&lt;input type="text" tabindex="8" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 9: &lt;/span&gt;&lt;input type="text" tabindex="9" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 10: &lt;/span&gt;&lt;input type="text" tabindex="10" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 11: &lt;/span&gt;&lt;input type="text" tabindex="11" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 12: &lt;/span&gt;&lt;input type="text" tabindex="12" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 13: &lt;/span&gt;&lt;input type="text" tabindex="13" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 14: &lt;/span&gt;&lt;input type="text" tabindex="14" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 15: &lt;/span&gt;&lt;input type="text" tabindex="15" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 16: &lt;/span&gt;&lt;input type="text" tabindex="16" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 17: &lt;/span&gt;&lt;input type="text" tabindex="17" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 18: &lt;/span&gt;&lt;input type="text" tabindex="18" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 19: &lt;/span&gt;&lt;input type="text" tabindex="19" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 20: &lt;/span&gt;&lt;input type="text" tabindex="20" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 21: &lt;/span&gt;&lt;input type="text" tabindex="21" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 22: &lt;/span&gt;&lt;input type="text" tabindex="22" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 23: &lt;/span&gt;&lt;input type="text" tabindex="23" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 24: &lt;/span&gt;&lt;input type="text" tabindex="24" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 25: &lt;/span&gt;&lt;input type="text" tabindex="25" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 26: &lt;/span&gt;&lt;input type="text" tabindex="26" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 27: &lt;/span&gt;&lt;input type="text" tabindex="27" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 28: &lt;/span&gt;&lt;input type="text" tabindex="28" /&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt;This is the code of the page that has the issue (testinput_iframe.html):&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Test input&lt;/title&gt; &lt;meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" /&gt; &lt;/head&gt; &lt;body&gt; &lt;iframe src="/testinput.html" /&gt; &lt;/body&gt; &lt;/html&gt;The issue is present in Safari on the iPhone, iPad and the xCode Simulator from version 8.4 to version 9.2.Someone know if this is a bug? There is way to fix it in css or javascript?Thanks and sorry for my english! 😉
9
0
22k
Jun ’22