I have made a custom class for UINavigationBar which has all the custom features I need for an application. After initialising the class I am adding it to the navigation controller like this
if (!navBar) {
navBar=[[NavigationBar alloc]initWithFrame:self.navigationController.navigationBar.frame];
[self.navigationController setValue:navBar forKeyPath:@"navigationBar"];
}
My app is crashing on the line
[self.navigationController setValue:navBar forKeyPath:@"navigationBar"];
Till Xcode 14 its working fine but on Xcode 15 it's crashing. Any help is highly appreciated.
below is the crash that I am getting
*** Assertion failure in -[UINavigationBar layoutSubviews], UINavigationBar.m:3856
I was able to solve the issue after putting the code in viewDidLayoutSubviews
-(void)viewDidLayoutSubviews{
[self.navigationController setValue:navBar forKeyPath:@"navigationBar"];
}
After this code is working and not crashing anymore