Hide navigation bar in iOS16 + xcode 14 beta not working - swift

We use Firebase's Crashlytics and in the last 2 days we've seen a spike in crashes with navigationController?.setNavigationBarHidden on iOS 16 devices. I was able to reproduce the crash after installing Xcode 14.5
I have a view controller (VC1) embedded in a navigational controller with the following code in
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
...
navigationController?.setNavigationBarHidden(false, animated: animated) // crash here
}
and after I push another view controller (VC2) using the following code
navigationController?.pushViewController(vc, animated: true)
the app crashes with the following error message
2022-08-10 15:07:04.866752-0700 autolist-dev[22341:3295980] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to activate constraint with anchors <NSLayoutXAxisAnchor:0x600001a9d740 "_UITAMICAdaptorView:0x7fd6c70ddbe0.leading"> and <NSLayoutXAxisAnchor:0x600001466680 "_UINavigationBarTitleControl:0x7fd6c70dcb80.leading"> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.'
It doesn't immediately crash the first time VC2 is pushed. After I go back to VC1 and then push VC2 again then the app crashes.
Does anyone have any ideas on how to resolve this? I can't seem to find anyone else having a similar issue

Related

How do I segue from uiviewcontroller to TabBarController

performSegue(withIdentifier: "m1", sender: self)
The code above is correct here below but it's giving me a SIGBRT (*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'm1'') error claiming the receiver login has no segue with identifier 'm1''
even the login is segued correctly to the UITabBarController with the correct identifier. Forgive me, i'm a beginner developer.
enter image description here
The call to perform the segue must be in the initial view controller, not the destination view controller. In this case, self.performSegue(withIdentifier:"m1", sender:self) should be in the UIViewController, and NOT the UITabBarController.

I can't Segue using a UIButton from UIViewController to UITableViewController

I'm getting Thread 1 SIGABRT in my AppDelegate class with the following
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController
loadView] instantiated view controller with identifier
"UIViewController-ynt-fo-t3z" from storyboard "Main", but didn't get a
UITableView.'
Storyboard arrangement:
UIViewController --> UITableViewController
I'm using a menu Button item from UIViewcontroller to trigger the segue. I have tried everything including preparedforSegue method. The only way around is to change the target view controller back to UIViewController while implementing UITableViewDelegate and UITableViewDataSource which I'm not too fond of using. Any solutions to my madness?
I had a similar issue long time ago; I tried anything, and nothing worked. I ended up using a new UITableViewController and segueing to it; And the issue was resolved. (it seemed like a bug in Xcode or something)
Do the same and see if it works for you.

Swift app crashes when popToRootViewController called - Exc Bad Access

My Swift app crashes when I have about 4 view controllers on my navigation stack and then at the 4th I call popToRootViewController. It pops, so I know the UINavigationController exists, but the app crashes without any error other than Exc Bad Access. It also crashes when I dismiss the UINavigationController instead of popping to root view controller.
Note: This happens only when running app on my test device. When my it's ran while my test device is connected to Xcode, it never crashes.
This is the only code in my final view controller, other than viewDidLoad of course.
Code:
#IBAction func closeBtnPressed(sender: AnyObject) {
//dismissViewControllerAnimated(true, completion: nil)
self.navigationController?.popToRootViewControllerAnimated(true)
}
Any ideas? Thanks!

Game Center share achievement or leaderboard crashes on iPad iOS 8

Hello everyone I am trying to implement Game Center on my iOS8 app and have run into a crash on the iPad. I already have the achievements and leaderboards set up and can successfully hit the blue share button on the iPhone but when i press share on the iPad the GKGameCenterViewController crashes and gives me the following report:
Application Specific Information:
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController
(<_UIAlertControllerActionSheetRegularPresentationController:
0x7b1480a0>) should have a non-nil sourceView or barButtonItem set
before the presentation occurs.' terminating with uncaught exception
of type NSException abort() called CoreSimulator 110.4 - Device: iPad
Retina - Runtime: iOS 8.1 (12B411) - DeviceType: iPad Retina
Any help would be appreciated thank you!
I got the same crash. When I present the GKGameCenterViewController modally, it's important I provide the sourceView, using the code in this order:
gameCenterVC.modalPresentationStyle = .Popover
gameCenterVC.popoverPresentationController?.sourceView = view!
gameCenterVC.popoverPresentationController?.sourceRect = view!.frame
presentViewController(gameCenterVC, animated: true, completion: {})
Your error reads
"reason: 'UIPopoverPresentationController [...]"
which suggests your modalPresentationStyle = .Popover.
In that case, you will need to set the source view or button bar, like the rest of the error indicates.
The instance popoverPresentationController in non-nil because...
If you created the view controller but have not yet presented it, accessing this property creates a popover presentation controller when the value in the modalPresentationStyle property is UIModalPresentationPopover
according to popoverPresentationController
I am testing on an iPad Air with iOS 9.3.
I am getting it to run without crashing [using my solution in the above post], but it does not display the game center popups or view controllers with
modalPresentationStyle = .Popover
However, I do get my view controllers and sign in pop ups when I set
modalPresentationStyle = .Fullscreen

How to create project without story board in xcode 6 (swift)?

Can any one has practiced creating project in xcode6 (swift) without storyboard.
I am able to implement
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
// Override point for customization after application launch.
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window!.backgroundColor = UIColor.whiteColor()
self.window!.makeKeyAndVisible()
var viewController: ViewController? = ViewController(nibName: "ViewController", bundle: nil)
self.navigationController = UINavigationController(rootViewController: viewController)
self.window!.rootViewController = self.navigationController
return true
}
but it fails with following error
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:
'-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "ViewController" nib but the
view outlet was not set.'
so i tried to relate file's owner UIView with xib, but i am unable to see UIView in file's owner property.
See the screen below
EDIT
Thanks Alex but from the second last point from HERE i am unable to find any view.
See the screen attached
I resolve my issue..
See the screen
Something strange with xcode6 beta, i am not sure whats wrong with it.
In Xcode 6 , you will get two custom class field in file inspector.you should enter your view controller name in second custom class field. when you enter the name then you can see view outlet under file owner properties.
Please ensure you have connected correctly your class with nib file. Especially, File's Owner setting. The same steps sequence for Swift as for Obj-C.
Try to reload XCode and re-save .nib file
See the instructions from here:
https://stackoverflow.com/a/6395750/2429147
or here:
https://stackoverflow.com/a/17321200/2429147