Post

Replies

Boosts

Views

Activity

Reply to Fatal Exception UIPopoverPresentationController that sourceView is nil after setting sourceView
(reply to @claude31 - not an answer but submitted as answer so code blocks are styled properly) The crash does not happen in all cases the code shared is executed. I’m not sure what the cases are that cause this crash because we cannot reproduce it. Based on logs, it seems like a lot of the crashes are happening with this code   @IBOutlet weak var borderLabel: UILabel! //from scene in storyboard ...    let anchorX = borderLabel.frame.width / 2    let anchorY = borderLabel.frame.height    let popoverPresentationController = tableViewController.setUpPopoverPresentation(     sourceView: borderLabel, sourceRect: CGRect(x: anchorX, y: anchorY, width: 0, height: 0))         popoverPresentationController.permittedArrowDirections = .up    present(tableViewController, animated: true, completion: nil) I did not show where setPopoverPresentationInfo() is called. I just included the function definition because it calls setUpPopoverPresentation(), and I shared all the places where setUpPopoverPresentation() is called. I think we use sourceRect with zero size as a default value. We don't get a crash every time we use a zero size because some places always use a zero size, and we can’t reproduce the crash in those places. What are the implications of setting a sourceRect with zero size? I don’t see much explaining how the size of sourceRect is used in https://developer.apple.com/documentation/uikit/uipopoverpresentationcontroller/1622324-sourcerect. Could you explain exactly how sourceRect is used? How does the size of the sourceRect affect the popover or sourceView? What is the difference between using the sourceView.bounds and using zero (or any other value) for the sourceRect size? Unfortunately, I can’t share our entire project, and these methods are called in different places. I know it may be difficult to see what all values are in the code snippets, but I’m hoping the issue may be apparent from what I shared. In the code you referenced:   let popoverPresentationController = dropdownTable.setUpPopoverPresentation(    sourceView: sourceView, sourceRect: sourceView.bounds.inset(.init(all: -5))) sourceRect is the second parameter name for setUpPopoverPresentation which is given sourceView.bounds.inset(.init(all: -5)). In the same code snippet, sourceView is another (the first) parameter name, which is passed sourceView as the parameter. The passed in sourceView is a UIButton of custom type with a normal attributedTitle set, sometimes a normal image set, sizeToFit() called on it, and other variables set for it as well. This (setUpPopoverPresentation) is called with the button as the sourceView parameter when a user taps on said button. Please see my original question for the setUpPopoverPresentation definition. If I can provide more information that could help (besides our entire project :) ), please let me know! Thank you!
Topic: UI Frameworks SubTopic: UIKit Tags:
Jul ’21
Reply to Fatal Exception UIPopoverPresentationController that sourceView is nil after setting sourceView
(here is hopefully an easier to read response to @Claude31) It only crashes on iPad, but we have a lot more functionality on iPad than iPhone, so it's possible the culprit flow is not available on iPhone. We call setUpPopoverPresentation in several different places. Here are snippets of how it is called: // BorderedButton is a subclass of UIButton private let button = BorderedButton(   normal: ColorPalette.LiveMessage.messageButtonBorderNormal,   highlighted: ColorPalette.LiveMessage.messageButtonBorderHighlighted) ... let popoverPresentationController = messagePopoverViewController.setUpPopoverPresentation(    sourceView: button, sourceRect: button.bounds) // within a method for creating dropdown popovers with table views - sourceView is of type UIView    let popoverPresentationController = dropdownTable.setUpPopoverPresentation(    sourceView: sourceView, sourceRect: sourceView.bounds.inset(.init(all: -5)))   @IBOutlet weak var borderLabel: UILabel! //from scene in storyboard ...    let anchorX = borderLabel.frame.width / 2    let anchorY = borderLabel.frame.height    let popoverPresentationController = tableViewController.setUpPopoverPresentation(     sourceView: borderLabel, sourceRect: CGRect(x: anchorX, y: anchorY, width: 0, height: 0))         popoverPresentationController.permittedArrowDirections = .up    present(tableViewController, animated: true, completion: nil) guard let senderView = sender as? UIView else {    return   }       let sourceRect =    CGRect(x: senderView.bounds.midX, y: senderView.bounds.maxY, width: 0, height: 0)   let popoverPresentationController = optionsViewController.setUpPopoverPresentation(    sourceView: senderView, sourceRect: sourceRect)   popoverPresentationController.permittedArrowDirections = .up   settingsContactViewController.present(optionsViewController, animated: true, completion: nil) // sourceView passed in is a UIButton func setPopoverPresentationInfo(sourceView: UIView, sourceRect: CGRect) {   let popoverPresentationController =    setUpPopoverPresentation(sourceView: sourceView, sourceRect: sourceRect)   popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)   popoverPresentationController.delegate = self   popoverPresentationController.popoverBackgroundViewClass = KeyboardPopoverBackgroundView.self   view.setNeedsLayout()  }
Topic: UI Frameworks SubTopic: UIKit Tags:
Jul ’21
Reply to Fatal Exception UIPopoverPresentationController that sourceView is nil after setting sourceView
We only see the crashes on iPad, but we have a lot more functionality on iPad than iPhone, so it's possible the culprit flow is not available on iPhone. We call setUpPopoverPresentation in several different places. Here are snippets of how it is called: // BorderedButton is a subclass of UIButton private let button = BorderedButton(   normal: ColorPalette.LiveMessage.messageButtonBorderNormal,   highlighted: ColorPalette.LiveMessage.messageButtonBorderHighlighted) ... let popoverPresentationController = messagePopoverViewController.setUpPopoverPresentation(    sourceView: button, sourceRect: button.bounds) // within a method for creating dropdown popovers with table views - sourceView is of type UIView    let popoverPresentationController = dropdownTable.setUpPopoverPresentation(    sourceView: sourceView, sourceRect: sourceView.bounds.inset(.init(all: -5)))   @IBOutlet weak var borderLabel: UILabel! //from scene in storyboard ...    let anchorX = borderLabel.frame.width / 2    let anchorY = borderLabel.frame.height    let popoverPresentationController = tableViewController.setUpPopoverPresentation(     sourceView: borderLabel, sourceRect: CGRect(x: anchorX, y: anchorY, width: 0, height: 0))         popoverPresentationController.permittedArrowDirections = .up    present(tableViewController, animated: true, completion: nil) guard let senderView = sender as? UIView else {    return   }       let sourceRect =    CGRect(x: senderView.bounds.midX, y: senderView.bounds.maxY, width: 0, height: 0)   let popoverPresentationController = optionsViewController.setUpPopoverPresentation(    sourceView: senderView, sourceRect: sourceRect)   popoverPresentationController.permittedArrowDirections = .up   settingsContactViewController.present(optionsViewController, animated: true, completion: nil) // sourceView passed in is a UIButton func setPopoverPresentationInfo(sourceView: UIView, sourceRect: CGRect) {   let popoverPresentationController =    setUpPopoverPresentation(sourceView: sourceView, sourceRect: sourceRect)   popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)   popoverPresentationController.delegate = self   popoverPresentationController.popoverBackgroundViewClass = KeyboardPopoverBackgroundView.self   view.setNeedsLayout()  }
Topic: UI Frameworks SubTopic: UIKit Tags:
Jul ’21
Reply to Fatal Exception UIPopoverPresentationController that sourceView is nil after setting sourceView
(reply to @claude31 - not an answer but submitted as answer so code blocks are styled properly) The crash does not happen in all cases the code shared is executed. I’m not sure what the cases are that cause this crash because we cannot reproduce it. Based on logs, it seems like a lot of the crashes are happening with this code   @IBOutlet weak var borderLabel: UILabel! //from scene in storyboard ...    let anchorX = borderLabel.frame.width / 2    let anchorY = borderLabel.frame.height    let popoverPresentationController = tableViewController.setUpPopoverPresentation(     sourceView: borderLabel, sourceRect: CGRect(x: anchorX, y: anchorY, width: 0, height: 0))         popoverPresentationController.permittedArrowDirections = .up    present(tableViewController, animated: true, completion: nil) I did not show where setPopoverPresentationInfo() is called. I just included the function definition because it calls setUpPopoverPresentation(), and I shared all the places where setUpPopoverPresentation() is called. I think we use sourceRect with zero size as a default value. We don't get a crash every time we use a zero size because some places always use a zero size, and we can’t reproduce the crash in those places. What are the implications of setting a sourceRect with zero size? I don’t see much explaining how the size of sourceRect is used in https://developer.apple.com/documentation/uikit/uipopoverpresentationcontroller/1622324-sourcerect. Could you explain exactly how sourceRect is used? How does the size of the sourceRect affect the popover or sourceView? What is the difference between using the sourceView.bounds and using zero (or any other value) for the sourceRect size? Unfortunately, I can’t share our entire project, and these methods are called in different places. I know it may be difficult to see what all values are in the code snippets, but I’m hoping the issue may be apparent from what I shared. In the code you referenced:   let popoverPresentationController = dropdownTable.setUpPopoverPresentation(    sourceView: sourceView, sourceRect: sourceView.bounds.inset(.init(all: -5))) sourceRect is the second parameter name for setUpPopoverPresentation which is given sourceView.bounds.inset(.init(all: -5)). In the same code snippet, sourceView is another (the first) parameter name, which is passed sourceView as the parameter. The passed in sourceView is a UIButton of custom type with a normal attributedTitle set, sometimes a normal image set, sizeToFit() called on it, and other variables set for it as well. This (setUpPopoverPresentation) is called with the button as the sourceView parameter when a user taps on said button. Please see my original question for the setUpPopoverPresentation definition. If I can provide more information that could help (besides our entire project :) ), please let me know! Thank you!
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Fatal Exception UIPopoverPresentationController that sourceView is nil after setting sourceView
(here is hopefully an easier to read response to @Claude31) It only crashes on iPad, but we have a lot more functionality on iPad than iPhone, so it's possible the culprit flow is not available on iPhone. We call setUpPopoverPresentation in several different places. Here are snippets of how it is called: // BorderedButton is a subclass of UIButton private let button = BorderedButton(   normal: ColorPalette.LiveMessage.messageButtonBorderNormal,   highlighted: ColorPalette.LiveMessage.messageButtonBorderHighlighted) ... let popoverPresentationController = messagePopoverViewController.setUpPopoverPresentation(    sourceView: button, sourceRect: button.bounds) // within a method for creating dropdown popovers with table views - sourceView is of type UIView    let popoverPresentationController = dropdownTable.setUpPopoverPresentation(    sourceView: sourceView, sourceRect: sourceView.bounds.inset(.init(all: -5)))   @IBOutlet weak var borderLabel: UILabel! //from scene in storyboard ...    let anchorX = borderLabel.frame.width / 2    let anchorY = borderLabel.frame.height    let popoverPresentationController = tableViewController.setUpPopoverPresentation(     sourceView: borderLabel, sourceRect: CGRect(x: anchorX, y: anchorY, width: 0, height: 0))         popoverPresentationController.permittedArrowDirections = .up    present(tableViewController, animated: true, completion: nil) guard let senderView = sender as? UIView else {    return   }       let sourceRect =    CGRect(x: senderView.bounds.midX, y: senderView.bounds.maxY, width: 0, height: 0)   let popoverPresentationController = optionsViewController.setUpPopoverPresentation(    sourceView: senderView, sourceRect: sourceRect)   popoverPresentationController.permittedArrowDirections = .up   settingsContactViewController.present(optionsViewController, animated: true, completion: nil) // sourceView passed in is a UIButton func setPopoverPresentationInfo(sourceView: UIView, sourceRect: CGRect) {   let popoverPresentationController =    setUpPopoverPresentation(sourceView: sourceView, sourceRect: sourceRect)   popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)   popoverPresentationController.delegate = self   popoverPresentationController.popoverBackgroundViewClass = KeyboardPopoverBackgroundView.self   view.setNeedsLayout()  }
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Fatal Exception UIPopoverPresentationController that sourceView is nil after setting sourceView
We only see the crashes on iPad, but we have a lot more functionality on iPad than iPhone, so it's possible the culprit flow is not available on iPhone. We call setUpPopoverPresentation in several different places. Here are snippets of how it is called: // BorderedButton is a subclass of UIButton private let button = BorderedButton(   normal: ColorPalette.LiveMessage.messageButtonBorderNormal,   highlighted: ColorPalette.LiveMessage.messageButtonBorderHighlighted) ... let popoverPresentationController = messagePopoverViewController.setUpPopoverPresentation(    sourceView: button, sourceRect: button.bounds) // within a method for creating dropdown popovers with table views - sourceView is of type UIView    let popoverPresentationController = dropdownTable.setUpPopoverPresentation(    sourceView: sourceView, sourceRect: sourceView.bounds.inset(.init(all: -5)))   @IBOutlet weak var borderLabel: UILabel! //from scene in storyboard ...    let anchorX = borderLabel.frame.width / 2    let anchorY = borderLabel.frame.height    let popoverPresentationController = tableViewController.setUpPopoverPresentation(     sourceView: borderLabel, sourceRect: CGRect(x: anchorX, y: anchorY, width: 0, height: 0))         popoverPresentationController.permittedArrowDirections = .up    present(tableViewController, animated: true, completion: nil) guard let senderView = sender as? UIView else {    return   }       let sourceRect =    CGRect(x: senderView.bounds.midX, y: senderView.bounds.maxY, width: 0, height: 0)   let popoverPresentationController = optionsViewController.setUpPopoverPresentation(    sourceView: senderView, sourceRect: sourceRect)   popoverPresentationController.permittedArrowDirections = .up   settingsContactViewController.present(optionsViewController, animated: true, completion: nil) // sourceView passed in is a UIButton func setPopoverPresentationInfo(sourceView: UIView, sourceRect: CGRect) {   let popoverPresentationController =    setUpPopoverPresentation(sourceView: sourceView, sourceRect: sourceRect)   popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)   popoverPresentationController.delegate = self   popoverPresentationController.popoverBackgroundViewClass = KeyboardPopoverBackgroundView.self   view.setNeedsLayout()  }
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jul ’21