How to configure ContextMenu buttons for delete and disabled in SwiftUI?

All of the asked situations are now supported in iOS 15 Destructive: (works from iOS 15) Set .destructive as the role argument of the button: Button(role: .destructive) { // 👈 This argument // delete something } label: { Label(“Delete”, systemImage: “trash”) } Disabled: (works from iOS 14.2) Add .disabled modifier to the button. Button { … Read more

iOS 13 Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP callback

On this thread from apple forums, someone from apple staff explained this: On iOS 13.0 and later, incoming Voice over IP calls must be reported when they are received and before the didReceiceIncomingPush() method finishes execution, using the CallKit framework, or the system will terminate your app. Repeatedly failing to report calls may prevent your … Read more

iOS13 share sheet: how to set preview thumbnail when sharing UIImage

The simplest code I’ve implemented to share a UIImage with better user experience: Import the LinkPresentation framework: #import <LinkPresentation/LPLinkMetadata.h> // for Obj-C import LinkPresentation // for Swift, below Present the UIActivityViewController in the UIViewController, with [image, self]: let image = UIImage(named: “YourImage”)! let share = UIActivityViewController(activityItems: [image, self], applicationActivities: nil) present(share, animated: true, completion: nil) … Read more

How to detect iPad and iPad OS version in iOS 13 and Up?

I was able to get iPad detection working by checking for navigator.maxTouchPoints as well as navigator.platform. It’s not perfect (as discussed in the comments below) but it’s the best solution I’ve come across so far so I wanted to share. const iPad = (userAgent.match(/(iPad)/) /* iOS pre 13 */ || (navigator.platform === ‘MacIntel’ && navigator.maxTouchPoints … Read more

Chaining animations in SwiftUI

As mentioned in the other responses, there is currently no mechanism for chaining animations in SwiftUI, but you don’t necessarily need to use a manual timer. Instead, you can use the delay function on the chained animation: withAnimation(Animation.easeIn(duration: 1.23)) { self.doSomethingFirst() } withAnimation(Animation.easeOut(duration: 4.56).delay(1.23)) { self.thenDoSomethingElse() } withAnimation(Animation.default.delay(1.23 + 4.56)) { self.andThenDoAThirdThing() } I’ve found … Read more

iOS 13 UIBarButtonItem not clickable and overlapping UINavigationBars when using UISearchController

The view debugger reveals what’s going on with this bug. The contents of the navigation bar are being copied. Here’s what the navigation bar looks like before you show the search: And here’s what it looks like afterwards: The two replicant views and the extra UILabel are the problem. I don’t know what they’re doing … Read more

UICollectionView and SwiftUI?

iOS 14 and Xcode 12 SwiftUI for iOS 14 brings a new and nativ grid view that is easy to use called LazyVGrid: https://developer.apple.com/documentation/swiftui/lazyvgrid You can start with defining an array of GridItems. GridItems are used to specify layout properties for each column. In this case all GridItems are flexible. LazyVGrid takes an array of … Read more