A common pattern (for me at least) in iOS 13 was to set navigation bar titles on subviews:
struct FlavorView: View {
		let items = ["Chocolate", "Vanilla", "Strawberry", "Mint Chip",
								 "Pistachio"]
		var body: some View {
				NavigationView {
						List(items, id: \.self) {
								Text($0)
						}
						.navigationBarTitle(Text("Today's Flavors"))
				}
		}
}
According to the documentation, this is now deprecated (https://developer.apple.com/documentation/swiftui/group/navigationbartitle(_:)-w0qq )
I couldn't find any other documentation on what the recommended way to set the navigation bar title now is. Can anybody point me in the right direction?
Post
Replies
Boosts
Views
Activity
When a navigation view is scrolled, common behaviour in iOS is for the large navigation title to collapse into the navigation bar.
When I place a TabView inside a NavigationView, this works perfectly. As the tab is scrolled, the large navigation title collapses:
NavigationView {
TabView {
LongList()
.tabItem({
Image(systemName: "circle")
Text("One")
})
LongList()
.tabItem({
Image(systemName: "square")
Text("Two")
})
}
.navigationTitle("Page Control Test")
}
When I set the tabViewStyle to PageTabViewStyle, the collapsing behaviour no longer works — the large navigation title remains even when scrolling:
NavigationView {
TabView {
LongList()
.tabItem({
Image(systemName: "circle")
Text("One")
})
LongList()
.tabItem({
Image(systemName: "square")
Text("Two")
})
}
	.tabViewStyle(PageTabViewStyle(indexDisplayMode: .always))
.navigationTitle("Page Control Test")
}
Is this behaviour intentional, or have I found a bug? This is running on iOS 14 beta 2 and the code was built on Xcode 12 beta 2.
The new ImageRenderer in SwiftUI is really great and should help me to remove some custom code I've had to write in the past.
I've noticed that when used to capture a view that contains a map view, the map is replaced with a 'no entry' sign 🚫
Is this intentional?
Here's some sample code to replicate the issue: https://gist.github.com/shaundon/282cf7ff276093681a1c246ae318c9d4
I'm trying to migrate my app from using NavigationView to NavigationStack and have run into an issue. It seems that when a View has a state variable with an optional type that's initialised as nil, then asynchronously changes to something other than nil, the view doesn't update.
If I use NavigationView it works fine, and if I initialise the state variable with something other than nil it also works fine.
I can't figure out why – any advice is appreciated. This is on iOS 6 beta 3.
struct ContentView: View {
// Initialise this as something other than nil and it'll work
// e.g. @State private var foo: String? = ""
@State private var foo: String? = nil
var body: some View {
// Change this to NavigationView and it'll work.
NavigationStack {
if let foo { Text(foo) }
// ProgressView never goes away
else { ProgressView() }
}
.task {
// Simulate loading some data asynchronously.
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
foo = "loaded"
}
}
}
}
View as a Gist on GitHub
On App Store Connect, we're required to upload a screenshot of in-app purchase screens to submit them for approval. Unfortunately the uploader only seems to work about 5% of the time, with it failing (see screenshot) every other time. I've tried several different browsers and it's the same every time.
Can something please be done about this? It's not acceptable for the developer tooling to be this buggy, and it's preventing many people from being able to submit in-app purchases.