I am working on a SwiftUI application. I am using a list which displays the response from the server. Once the user clicks on the list item, it opens up a new view which loads another data from the server on some textviews and buttons. However, when the data fully loads, the back button disables. Please refer to the attached video. [https://1drv.ms/v/s!Au1n19s_ZcghxgssOZFa_6vcUxBO?e=9xZUGh]
Back button removed in the navigation bar once the view loads
Can anybody help. Is this a bug or I am doing something wrong. I have attached a video as well.
If you would like to enhance the chance to be helped, you should better show your code rather than a video. Create a project, simplified but enough to reproduce the issue, and show all the code in the project.
@OOPer the file is large almost 700 lines and to help someone run it... I will have to make many changes to it. I will try to do something on my end. Thanks anyway.
@OOPer found the issue. I am using custom toolbar using .toolbar which is causing this issue. I removed it and it works fine. Need to have a work around for this.
I had a view that used to be opened from a list. The view contained a scrollview and all the items are listed in it including the TextFields, Texts, Button, Picker and others. I was using a custom modifier in the toolbar trialing items to show a notification Sheet and a logout button.
Below is the custom code:
ScrollView{
// some code
}.toolbar(){
ToolbarItem(placement: .navigationBarTrailing){
Logout().environmentObject(settings)
}
}
The logout class held the messaging sheet and the logout button. This caused the back button to be disappearing whenever the view loaded. I have now changed it to:
ScrollView{
//some code
}
.navigationBarItems(trailing: Logout().environmentObject(settings))