SwiftUI Popover Crash on iPad During Resizing in Stage Manager with Exception.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Trying to layout popover in the delegate callback popoverPresentationController:willRepositionPopoverToRect:inView: will lead to recursion. Do not force the popover's container view or an ancestor to layout in this callback.'
(Occurred from iPadOS 18.1)
struct ContentView: View {
@State var showPopover: Bool = false
var body: some View {
VStack {
Text("Hello, world!")
Button(action: {
showPopover = true
}, label: {
Text("Open Popover")
})
}
.padding()
.popover(isPresented: $showPopover, attachmentAnchor: .point(.trailing), content: {
VStack {
Text("Popover Content")
}
})
}
}
Post
Replies
Boosts
Views
Activity
I'm facing an issue with the enumerateContent method in my Contact Provider extension. The method is being called multiple times before I call the first observer.didEnumerate..
Here's a sample of my code:
class TestContactProviderRootContainerEnumerator : ContactItemEnumerator {
let handler = TestContactProviderUsecaseHandler()
func configure(for domain: ContactProviderDomain) {
log.error("---> configure")
}
func enumerateContent(in page: ContactItemPage, for observer: ContactItemContentObserver) {
let requestPage = getPageIndex(from: page.offset, pageSize: observer.suggestedPageSize)
log.error("---> Begin Enumerate Content page=\(requestPage) pageSize =\(observer.suggestedPageSize)")
func completion(items: [ContactItem], hasMore: Bool) {
observer.didEnumerate(items)
do {
let generationMarker = try getGenerationMarker(page: page)
if hasMore {
let nextPage = ContactItemPage(generationMarker: generationMarker, offset: page.offset + items.count)
log.error("---> nextPage set offset \(page.offset + items.count) nextPage: \(getPageIndex(from: page.offset + items.count, pageSize: observer.suggestedPageSize))")
observer.didFinishEnumeratingPage(upTo: nextPage)
}else {
observer.didFinishEnumeratingContent(upTo: generationMarker)
}
}catch {
observer.didFinishEnumeratingContentWithError(error)
return
}
}
log.error("---> Start Request page=\(requestPage) pageSize =\(observer.suggestedPageSize)")
handler.requestForRecordsList(page: requestPage, perPage: observer.suggestedPageSize, sortBy: Field.Contact.lastName, modifiedSince: nil, completion: { contactItems, hasMore, error in
log.error("---> Finish Request page=\(requestPage) pageSize =\(observer.suggestedPageSize)")
if let error {
log.error("---> Error: \(error)")
observer.didFinishEnumeratingContentWithError(error)
return
}
completion(items: contactItems, hasMore: hasMore)
log.error("---> End Enumerate Content page=\(requestPage) pageSize =\(observer.suggestedPageSize)")
})
}
}
Below are the logs that I'm seeing:
---> configure
---> Begin Enumerate Content page=1 pageSize =20
---> Start Request page=1 pageSize =20
---> Begin Enumerate Content page=1 pageSize =20
---> Begin Enumerate Content page=1 pageSize =20
---> Begin Enumerate Content page=1 pageSize =20
....10+times
---> Begin Enumerate Content page=1 pageSize =20
---> Finish Request page=1 pageSize =20
---> Begin Enumerate Content page=1 pageSize =20
---> nextPage set offset 20 nextPage: 2
---> Begin Enumerate Content page=1 pageSize =20
---> Begin Enumerate Content page=1 pageSize =20
---> Begin Enumerate Content page=2 pageSize =20
---> Begin Enumerate Content page=2 pageSize =20
---> Start Request page=2 pageSize =20
---> Begin Enumerate Content page=2 pageSize =20
---> Begin Enumerate Content page=2 pageSize =20
....10+times
---> Begin Enumerate Content page=2 pageSize =20
---> Begin Enumerate Content page=2 pageSize =20
Has anyone else experienced this issue? Any ideas on why this is happening or how to fix it.
From iOS 17 beta, the Contact app has an interactive widget with a call and message button, that will open Phone, messenger, Instagram, WhatsApp, etc.
it's any API available to open another app from widget.
I'm Presenting UIPageViewController, each page has UItableView. Pull-down gesture to dismiss not working in UIPageViewControllerTransitionStyle.scroll, but it's working fine in pageCurl style.
PageViewController
class PageViewController: UIPageViewController, UIPageViewControllerDataSource {
let pages: [UIViewController]
init(pages: [UIViewController]) {
self.pages = pages
super.init(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
if let viewController = self.pages.first {
self.setViewControllers([viewController], direction: .forward, animated: true)
}
}
//MARK: UIPageViewControllerDataSource
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
guard let index = self.pages.firstIndex(of: viewController), index + 1 < tabVsViewController.count else {
return nil
}
return self.pages[index + 1]
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
guard let index = self.pages.firstIndex(of: viewController), index - 1 >= .zero else {
return nil
}
return self.pages[index - 1]
}
}
let bottomView = PageViewController(pages: viewControllers)
bottomView.preferredContentSize = CGSize(width: self.view.bounds.width ?? 0.0, height: 300.0)
bottomView.modalPresentationStyle = .formSheet
let sheetPresentation = bottomView.sheetPresentationController
sheetPresentation?.detents = [.medium(), .large()]
sheetPresentation?.selectedDetentIdentifier = .medium
sheetPresentation?.preferredCornerRadius = 20.0
sheetPresentation?.prefersGrabberVisible = true
self.present(bottomView, animated: true, completion: nil)
HI, ContentSize is incorrect in UITableView grouped style in iOS15.4, I run this below code in iOS 15.4 using Xcode 13.1 which has the content size 40 (cell 0 height + cell 1 height), and it works fine. But in the Xcode 13.3.1 content size is approximately 60.
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
lazy var tableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
tableView.backgroundColor = UIColor.lightGray
tableView.sectionHeaderTopPadding = 0.01
tableView.delegate = self
tableView.dataSource = self
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.register(TableViewCell.self, forCellReuseIdentifier: "TableViewCell")
return tableView
}()
override func viewDidLoad() {
super.viewDidLoad()
self.view.addSubview(tableView)
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
tableView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
}
//MARK: UITableViewDataSource & UITableViewDelegate
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TableViewCell") as! TableViewCell
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 20
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return nil
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return CGFloat.leastNormalMagnitude
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return nil
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return CGFloat.leastNormalMagnitude
}
}
class TableViewCell: UITableViewCell {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.backgroundColor = .red
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
I'm creating an iOS and macCatalyst app with drag and drop contacts vCard, it's working fine in the iPad "Drag contact vCard from my app and able to drop in default Contact and other apps", In macCatalyst can't able drop vCard item to the default Contacts app
NSItemProviderWriting
final class ContactItem: NSObject, NSItemProviderWriting {
var data: Data
private static let CONTACT_V_CARD = "public.vcard"
static var writableTypeIdentifiersForItemProvider: [String] = [
CONTACT_V_CARD
]
init(_ name: String) throws {
let cnContact = CNMutableContact()
cnContact.givenName = name
let data = try CNContactVCardSerialization.data(with: [cnContact])
self.data = data
}
func loadData(withTypeIdentifier typeIdentifier: String, forItemProviderCompletionHandler completionHandler: @escaping (Data?, Error?) -> Void) -> Progress? {
let progress = Progress(totalUnitCount: 100)
progress.completedUnitCount = 100
completionHandler(data, nil)
return progress
}
}
I have created datePicker with locale and timezone as like
datePicker.locale = Locale(identifier: "en_US")
datePicker.timeZone = TimeZone(identifier: "Brazil/East")
datePicker.date = Date() // 2020-08-03 08:46:13 +0000
my device timezone is "Asia/Kolkata"
In datePicker wheels style its show time as "5:46 AM" but
Inline style shows "2:16 PM"
inline style always shows the time in current device timeZone irrespective of the configured datePicker.timeZone