I’m following the example code from Apple to implement the new iPadOS 18 TabView() with the new Tab(). While the tabbing itself is working fine, I can’t get it to show up a (large) navigation title in the sidebar (like the Home or Files app).
I’ve tried placing .navigationTitle("App Name") at the TabView, but that doesn’t work. Is it possible to do this in any way or is this not recommended to show?
TabView {
Tab("Overview", systemImage: "film") {
Text("Put a OverviewView here")
}
TabSection("Watch") {
Tab("Movies", systemImage: "film") {
Text("Put a MoviesView here")
}
Tab("TV Shows", systemImage: "tv") {
Text("Put a TVShowsView here")
}
}
TabSection("Listen") {
Tab("Music", systemImage: "music.note.list") {
Text("Put a MusicView here")
}
Tab("Podcasts", systemImage: "mic") {
Text("Put a PodcastsView here")
}
}
}
.tabViewStyle(.sidebarAdaptable)
.navigationTitle("App Name")
.navigationBarTitleDisplayMode(.large)
I know that there is also the .tabViewSidebarHeader() modifier, but that adds any view above the scroll view content. Neither does that easily allow to make it look like the regular navigation title, nor does it actually display in the navigation bar at the top, when scrolling down.
SwiftUI
RSS for tagProvide views, controls, and layout structures for declaring your app's user interface using SwiftUI.
Post
Replies
Boosts
Views
Activity
In iOS 18 widget, button is broken when it's has an accented desaturated image as content, the button's AppIntent will not trigger perform function.
checkout the code below:
`
struct WidgetExtEntryView : View {
var entry: Provider.Entry
var body: some View {
VStack {
Text("count:")
Text("\(WidgetExtAppIntent.count)")
HStack {
// button can not be tapped
Button(intent: WidgetExtAppIntent(action: "+1")) {
VStack {
Image(systemName: "plus.square.fill").resizable()
.widgetAccentedRenderingMode(.accentedDesaturated) // <-- here
.frame(width: 50, height: 50)
Text("Broken")
}
}.tint(.red)
// button can be tapped
Button(intent: WidgetExtAppIntent(action: "+1")) {
VStack {
Image(systemName: "plus.square.fill").resizable()
.widgetAccentedRenderingMode(.fullColor) // <-- here
.frame(width: 50, height: 50)
Text("OK").frame(width: 50, alignment: .center)
}
}.tint(.green)
}
.minimumScaleFactor(0.5)
}
}
}
`
check out the full demo project: ButtonInWidgetBrokenIOS18
I have a NavigationSplitView with all three columns, and NavigationLinks in the sidebar to present different Lists for the content column. When a list item is selected in the content view, I want to present a view in the detail view. Since different detail views should be presented for different content views, I represent state like this (some details omitted for space):
// Which detail view to show in the third column
enum DetailViewKind: Equatable {
case blank
case localEnv(RegistryEntry)
case package(SearchResult)
}
// Which link in the sidebar was tapped
enum SidebarMenuItem: Int, Hashable, CaseIterable {
case home
case localEnvs
case remoteEnvs
case packageSearch
}
// Binds to a DetailViewKind, defines the activate SidebarMenuItem
struct SidebarView: View {
@State private var selectedMenuItem: SidebarMenuItem?
@Binding var selectedDetailView: DetailViewKind
var body: some View {
VStack(alignment: .leading, spacing: 32) {
SidebarHeaderView()
Divider()
// Creates the navigationLinks with a SidebarMenuRowView as labels
SidebarMenuView(selectedMenuItem: $selectedMenuItem, selectedDetailView: $selectedDetailView)
Spacer()
Divider()
SidebarFooterView()
}
.padding()
.frame(alignment: .leading)
}
}
struct SidebarMenuRowView: View {
var menuItem: SidebarMenuItem
@Binding var selectedMenuItem: SidebarMenuItem?
@Binding var selectedDetailView: DetailViewKind
private var isSelected: Bool {
return menuItem == selectedMenuItem
}
var body: some View {
HStack {
Image(systemName: menuItem.systemImageName).imageScale(.small)
Text(menuItem.title)
Spacer()
}
.padding(.leading)
.frame(height: 24)
.foregroundStyle(isSelected ? Color.primaryAccent : Color.primary)
.background(isSelected ? Color.menuSelection : Color.clear)
.clipShape(RoundedRectangle(cornerRadius: 10))
.navigationDestination(for: SidebarMenuItem.self) { item in
navigationDestinationFor(menuItem: item, detailView: $selectedDetailView)
}
.onTapGesture {
if menuItem != selectedMenuItem {
selectedMenuItem = menuItem
}
}
}
}
// Determines which detail view to present
struct DetailView: View {
@Binding var selectedDetailView: DetailViewKind
var innerView: some View {
switch selectedDetailView {
case .blank:
AnyView(Text("Make a selection")
.font(.subheadline)
.foregroundStyle(.secondary)
.navigationSplitViewColumnWidth(min: 200, ideal: 350))
case .localEnv(let regEntry):
AnyView(EnvironmentDetailView(regEntry: regEntry))
case .package(let searchResult):
AnyView(PackageDetailView(searchResult: searchResult))
}
}
var body: some View {
innerView
}
}
struct ContentView: View {
@State private var detailView: DetailViewKind = .blank
var body: some View {
NavigationSplitView {
SidebarView(selectedDetailView: $detailView)
.navigationSplitViewColumnWidth(175)
} content: {
HomeView()
.navigationSplitViewColumnWidth(min: 300, ideal: 450)
}
detail: {
DetailView(selectedDetailView: $detailView)
}
}
}
My issue is that the detail view is not updated when the ContentView's detailView property is updated. I've verified that the value itself is changing, but the view is not. I searched around to see why this would be (this is my first Swift/SwiftUI application) and from what I gather a @Binding alone will not cause a view to be updated, that binding either needs to be used in the view hierarchy, or it needs to be stored as a @State property that gets updated when the binding value changes. I added a dummy @State property to DetailView and that still doesn't work, so I'm a little confused:
struct DetailView: View {
@Binding var selectedDetailView: DetailViewKind
@State private var dummyProp: DetailViewKind?
var innerView: some View {
switch selectedDetailView {
case .blank:
AnyView(Text("Make a selection")
.font(.subheadline)
.foregroundStyle(.secondary)
.navigationSplitViewColumnWidth(min: 200, ideal: 350))
case .localEnv(let regEntry):
AnyView(EnvironmentDetailView(regEntry: regEntry))
case .package(let searchResult):
AnyView(PackageDetailView(searchResult: searchResult))
}
}
var body: some View {
innerView.onChange(of: selectedDetailView) {
dummyProp = selectedDetailView
}
}
}
Any ideas?
Hi,
I have a form on an iPad App I'm developing and the form have text field at its bottom when tapping on it the keyboard cover those text fields how to solve this issue leave a hug gap at bottom of the form so text field jump to top when keyboard shows ?
Kind Regards
We're seeing sporadic crashes on devices running iOS 18.1 - both beta and release builds (22B83). The stack trace is always identical, a snippet of it below. As you can tell from the trace, it's happening in places we embed SwiftUI into UIKit via UIHostingController.
Anyone else seeing this?
4 libobjc.A.dylib 0xbe2c _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 30
5 libobjc.A.dylib 0xb040 weak_register_no_lock + 396
6 libobjc.A.dylib 0xac50 objc_storeWeak + 472
7 libswiftCore.dylib 0x43ac34 swift_unknownObjectWeakAssign + 24
8 SwiftUI 0xeb74c8 _UIHostingView.base.getter + 160
9 SwiftUI 0x92124 _UIHostingView.layoutSubviews() + 112
10 SwiftUI 0x47860 @objc _UIHostingView.layoutSubviews() + 36
I can't shake the "I don't think I did this correctly" feeling about a change I'm making for Image Playground support.
When you create an image via an Image Playground sheet it returns a URL pointing to where the image is temporarily stored. Just like the Image Playground app I want the user to be able to decide to edit that image more.
The Image Playground sheet lets you pass in a source URL for an image to start with, which is perfect because I could pass in the URL of that temp image.
But the URL is NOT optional. So what do I populate it with when the user is starting from scratch?
A friendly AI told me to use URL(string: "")! but that crashes when it gets forced unwrapped.
URL(string: "about:blank")! seems to work in that it is ignored (and doesn't crash) when I have the user create the initial image (that shouldn't have a source image).
This feels super clunky to me. Am I overlooking something?
I'm trying to test migration between schemas but I cannot get it to work properly. I've never been able to get a complex migration to work properly unfortunately. I've removed a property and added 2 new ones to one of my data models.
This is my current plan.
enum MigrationV1toV2: SchemaMigrationPlan {
static var schemas: [any VersionedSchema.Type] {
[SchemaV1.self, SchemaV2.self]
}
static let migrateV1toV2 = MigrationStage.custom(
fromVersion: SchemaV1.self,
toVersion: SchemaV2.self,
willMigrate: { context in
print("Inside will migrate")
// Get old months
let oldMonths = try context.fetch(FetchDescriptor<SchemaV1.Month>())
print("Number of old months:\(oldMonths.count)")
for oldMonth in oldMonths {
// Convert to new month
let newMonth = Month(name: oldMonth.name, year: oldMonth.year, limit: oldMonth.limit)
print("Number of transactions in oldMonth: \(oldMonth.transactions?.count)")
print("Number of transactions in newMonth: \(newMonth.transactions?.count)")
// Convert transactions
for transaction in oldMonth.transactions ?? [] {
// Set action and direction
let action = getAction(from: transaction)
let direction = getDirection(from: transaction)
// Update category if necessary
var category: TransactionCategory? = nil
if let oldCategory = transaction.category {
category = TransactionCategory(
name: oldCategory.name,
color: SchemaV2.Category.Colors.init(rawValue: oldCategory.color?.rawValue ?? "") ?? .blue,
icon: getCategoryIcon(oldIcon: oldCategory.icon)
)
// Remove old category
context.delete(oldCategory)
}
// Create new
let new = Transaction(
date: transaction.date,
action: action,
direction: direction,
amount: transaction.amount,
note: transaction.note,
category: category,
month: newMonth
)
// Remove old transaction from month
oldMonth.transactions?.removeAll(where: { $0.id == transaction.id })
// Delete transaction from context
context.delete(transaction)
// Add new transaction to new month
newMonth.transactions?.append(new)
}
// Remove old month
context.delete(oldMonth)
print("After looping through transactions and deleting old month")
print("Number of transactions in oldMonth: \(oldMonth.transactions?.count)")
print("Number of transactions in newMonth: \(newMonth.transactions?.count)")
// Insert new month
context.insert(newMonth)
print("Inserted new month into context")
}
// Save
try context.save()
}, didMigrate: { context in
print("In did migrate")
let newMonths = try context.fetch(FetchDescriptor<SchemaV2.Month>())
print("Number of new months after migration: \(newMonths.count)")
}
)
static var stages: [MigrationStage] {
[migrateV1toV2]
}
}
It seems to run fine until it gets the the line: try context.save(). At this point it fails with the following line:
SwiftData/PersistentModel.swift:726: Fatal error: What kind of backing data is this? SwiftData._KKMDBackingData<Monthly.SchemaV1.Transaction>
Anyone know what I can do about this?
Whenever I start editing TextField or while editing TextField, Xcode shows this worning, and takes a few seconds to show the keyboard.
There is no 'availabilityDetailedInfo' in my source code, and I could not find similar errors on the internet.
Can't find or decode availabilityDetailedInfo
unavailableReasonsHelper: Failed to get or decode availabilityDetailedInfo
Can't find or decode reasons
unavailableReasonsHelper: Failed to get or decode unavailable reasons as well
Can't find or decode availabilityDetailedInfo
unavailableReasonsHelper: Failed to get or decode availabilityDetailedInfo
Can't find or decode reasons
unavailableReasonsHelper: Failed to get or decode unavailable reasons as well
I have a SwiftUI view of the form
struct ContentView: View {
// ...
.onDrop(of: [.pdf], isTargeted: $isDropTargeted) { pdfs in
for pdf in pdfs {
I'm just not sure what to do next, I see there's a loadPreviewImage() that if I use like:
Task.detached {
// returns any NSSecureCoding object
let image = try! await pdf.loadPreviewImage()
}
Not sure how I'm supposed to get my preview image from that NSSecureCoding object
When I try to launch a ShareLink from within a fullScreenCover, I get the following error:
Attempt to present <UIActivityViewController: 0x105e6a400> on <_TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVS_7AnyViewVS_12RootModifier__: 0x1053a37c0> (from <_TtGC7SwiftUI19UIHostingControllerVVS_7TabItem8RootView_: 0x105eb8a00>) which is already presenting <_TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView_: 0x114890000>
Seems like a bug, has anyone else encountered this or found a way around it?
Am in the process of migrating some UIKit based apps over to SwiftUI, but for the life of me I cannot find the SwiftUI equivalent of Readable Content Margins.
I have come across some workarounds that kind of, sort of work, but do not produce the same results when compared to running the same user interface written using UIKit on several sizes of iPads in portrait and landscape orientiations.
is it something Apple has not gotten around to yet, because I realize SwiftUI is a work-in-progress, or do we not care about creating consistent readable margins in our apps anymore?
Over and over I see claims that you can use ButtonStyle to style the appearance of NavigationLinks. But in my experience, this does not work.
What's going on here? In the screen shot, the list items (NavigationLinks) are styled with the same button style as the button below them. As you can see, this does nothing.
Code for the whole view:
// ContentView.swift
import SwiftUI
struct UserMessage : Hashable
{
var title: String
var text: String
}
let inMessages = [UserMessage(title: "Inbound 1", text: "Test message!"), UserMessage(title: "Inbound 2", text: "Test message!"), UserMessage(title: "Inbound 3", text: "Test message!")]
let outMessages = [UserMessage(title: "Outbound 1", text: "Test message!"), UserMessage(title: "Outbound 2", text: "Test message!"), UserMessage(title: "Outbound 3", text: "Test message!")]
struct NavLinkButton: ButtonStyle
{
func makeBody(configuration: Configuration) -> some View
{
configuration.label
.frame(maxWidth: .infinity)
.padding()
.foregroundStyle(.purple)
.background(configuration.isPressed ? .blue : .green)
.clipShape(RoundedRectangle(cornerRadius: 10))
.overlay {
RoundedRectangle(cornerRadius: 10)
.stroke(.red, lineWidth: configuration.isPressed ? 2 : 0)
}
.padding(3)
}
}
struct ContentView: View
{
var body: some View
{
NavigationStack
{
messageList(msgsIn: inMessages, msgsOut: outMessages)
.frame(maxWidth: 400, maxHeight: 400)
Button(action: {}, label: { Text("Styled button") })
.buttonStyle(NavLinkButton())
.frame(maxWidth: 400)
Spacer()
}
}
@ViewBuilder func messageList(msgsIn: [UserMessage], msgsOut: [UserMessage]) -> some View
{
List
{
Section(header: Text("Your Inbox"))
{
ForEach(msgsIn, id: \.self) { aMsg in
NavigationLink(destination: MessageDetailView(withMessage: aMsg), label: { Text("\(aMsg.title)") })
.buttonStyle(NavLinkButton())
}
.listRowBackground(Color.clear)
}
Section(header: Text("Your Outbox"))
{
ForEach(msgsOut, id: \.self) { aMsg in
NavigationLink(destination: MessageDetailView(withMessage: aMsg), label: { Text("\(aMsg.title)") })
.buttonStyle(NavLinkButton())
}
.listRowBackground(Color.clear)
}
}
.scrollContentBackground(.hidden)
}
}
struct MessageDetailView: View
{
var message: UserMessage?
init(withMessage: UserMessage)
{
message = withMessage
}
var body: some View
{
Text(message?.title ?? "")
}
}
Starting with iOS 18, the behavior of searchable and searchSuggestions differs from previous versions.
In iOS 17.5, searchSuggestions remained visible even after selecting an item and navigating away. However, in iOS 18, searchSuggestions are dismissed after navigation.
Is there a way to keep searchSuggestions visible after navigation, as in iOS 17.5?
struct ContentView: View {
@State private var query = ""
var body: some View {
NavigationStack {
Color.red
.searchable(text: $query)
.searchSuggestions {
NavigationLink("Element") {
Color.blue
}
}
}
}
}
iOS 18.1
iOS 17.5
We've seen an issue when using a LazyVGrid inside a List. The app crashes with:
Thread 1: Fatal error: <UpdateCoalescingCollectionView 0x600000ca0d20> is stuck in a recursive layout loop
When debugging the issue, we were able to narrow down the issue to a minimum reproducible example below:
struct ContentView: View {
let columns = [
GridItem(.adaptive(minimum: 43))
]
var body: some View {
List {
LazyVGrid(columns: columns) {
ForEach(0..<15) { value in
if value == 0 {
Text("a")
} else {
Color.clear
}
}
}
}
}
}
The issue can be reproduced on iPhone 15 Pro Max and iOS 18.x specifically.
In a production app we have a similar layout, but instead of GridItem(.adaptive) we use GridItem(.flexible).
Hi,
I'm working on an app that will mostly live in the menu bar.
I'm trying to make a menu item that looks similar to the Tailscale app's menu:
Note: I'm inspired by how Tailscale's menu is rendered:
I have made a View that shows my avatar, name, and optionally the company I work for:
import SwiftUI
struct MenuWhoAmI: View {
var username: String
var binding: String?
var body: some View {
HStack {
AsyncImage(url: URL(string: "https://avatars.githubusercontent.com/u/76716")!){ image in
image.resizable().scaledToFit()
} placeholder: {
ProgressView()
}
.clipShape(Circle())
VStack(alignment: .leading) {
Text(username)
if let binding = binding {
Text("\(binding)").foregroundStyle(.secondary)
}
}
}
}
}
#Preview {
VStack(alignment: .leading) {
MenuWhoAmI(username: "grahamc").padding()
Divider()
MenuWhoAmI(username: "grahamc", binding: "DeterminateSystems").padding()
}.padding()
}
I tried using it in my menu bar:
import SwiftUI
@main
struct DeterminateApp: App {
var body: some Scene {
MenuBarExtra("Determinate", image: "MenuIcon") {
MenuWhoAmI(username: "grahamc")
Button("Two") {}
Button("Three") {}
Divider()
Button("Quit") {
NSApplication.shared.terminate(nil)
}.keyboardShortcut("q")
}.menuBarExtraStyle(.menu)
}
}
and it renders differently:
After reading the forums and documentation, I understood the MenuBarExtra only renders certain elements. I then tried to use an NSStatusBar with an AppDelegate:
import AppKit
import SwiftUI
@main
struct DeterminateApp: App {
@NSApplicationDelegateAdaptor private var appDelegate: AppDelegate
var body: some Scene {
Window("Authentication", id: "login") {}
}
}
class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
private var statusItem: NSStatusItem!
func applicationDidFinishLaunching(_ notification: Notification) {
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
if let button = statusItem.button {
button.image = NSImage(named: NSImage.Name("MenuIcon"))
}
statusItem.menu = NSHostingMenu(rootView: Group {
Button(action: { print("hi") }) {
MenuWhoAmI(username: "grahamc")
}
})
}
}
and still, the avatar/name doesn't render like I'd expect, missing the circle clipping:
...and I'm a bit mystified.
How can I make this menu render the way I'm trying for?
Thank you!
I've read all previous posts on this topic but none seem to address what I'm seeing for iOS 16 and using NavigationStack. I'm also using an overall @EnvironmentObject for navigation state.
I have a split view app. In the detail section, I have a NavigationStack surrounding the detail view. Within the detail view (MyView), there is a base view with a "+" button in the toolbar to create a new entity.
That opens NewEntityView where I show a grid of buttons for the user to select a type to create a new entity before moving to NewEntityView to fill in the details for the entity. The top row of the grid of buttons takes the user straight to the NewEntityView with a NavigationLink. These work fine.
The next row of buttons present a menu of sub-types and then should take the user to the NewEntityView view. These buttons do not work.
Code (simplified to not have clutter):
SplitViewDetailView:
struct SplitViewDetailView: View {
@EnvironmentObject var navigationManager: NavigationStateManager
@Binding var selectedCategory: Route?
var body: some View {
NavigationStack(path: $navigationManager.routes) {
// other irrelevant stuff
MyView()
}
.environmentObject(navigationManager)
.navigationDestination(for: Route.self) { $0 }
}
}
MyView:
struct MyView: View {
@EnvironmentObject var navigationManager: NavigationStateManager
var body: some View {
List {
// other stuff
}
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: {}, label: {
NavigationLink(value: Route.newTypeSelect) {
Image(systemName: "plus")
.frame(width: 44, height: 44)
}
} )
}
}
.navigationDestination(for: Route.self) { $0 }
}
SelectTypeView:
struct SelectTypeView: View {
var body: some View {
ZStack {
VStack {
// Top row with no subtypes
HStack {
ForEach (topRows, id: \.self) { type in
NavigationLink(value: Route.newEntityDetails(type.rawValue)) { <-- these work
Text(type)
}
}
}
HStack {
ForEach (middleRow, id: \.self) { type in
Menu {
ForEach (subtype[type], id: \.self) { sub in
NavigationLink(value: Route.newEntityDetails(sub.rawValue)) { <-- these go nowhere
Text(sub)
}
}
} label: {
Text(type)
}
}
}
}
}
}
}
NavigationStateManager:
class NavigationStateManager: ObservableObject {
@Published var routes = [Route]()
// other stuff
}
And Route:
enum Route: Identifiable {
var id: UUID { UUID() }
case newTypeSelect
case newEntityDetails(String)
}
extension Route: View {
var body: some View {
switch self {
case .newTypeSelect:
SelectTypeView()
case .newEntityDetails(let type):
NewEntityView(selectedType: type)
}
}
}
The menus show up fine but tapping on an item does nothing. I've attempted to wrap the menu in its own NavigationStack but that is rejected stating it is already in one defined by a parent view. I've tried making the links Buttons with destinations and those are also rejected.
What is the newest/best way to present a menu with NavigationLinks? One doesn't simply wrap the menu in a NavigationView if one is using a NavigationStack?
I am using the TabView control in SwiftUI on a tvOS 18 target with the style of sidebarAdaptable. When I have 7 or less tabs things operate correctly. When I add an 8th tab and you navigate to the contents of the tab the menu collapses as expected but you cannot navigate back to restore the menu. This code reproduces the issue:
import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
Tab("Tab1", systemImage: "person.circle") {
Button("Button1") {}
}
Tab("Tab2", systemImage: "person.circle") {
Button("Button2") {}
}
Tab("Tab3", systemImage: "person.circle") {
Button("Button3") {}
}
Tab("Tab4", systemImage: "person.circle") {
Button("Button4") {}
}
Tab("Tab5", systemImage: "person.circle") {
Button("Button5") {}
}
Tab("Tab6", systemImage: "person.circle") {
Button("Button6") {}
}
Tab("Tab7", systemImage: "person.circle") {
Button("Button7") {}
}
Tab("Tab8", systemImage: "person.circle") {
Button("Button8") {}
}
}
.tabViewStyle(.sidebarAdaptable)
}
}
If you eliminate Tab 8 the problem goes away. You can navigate back to the menu by moving to the left.
Notably the Destination Video sample also reproduces this issue:
https://developer.apple.com/documentation/visionos/destination-video
To reproduce:
Load the above code or Destination Video sample.
Navigate right (click right on remote or swipe right). Menu dismisses and just shows the item you have selected in the upper left corner.
Try to navigate left by clicking left on the remote or swiping left. It looks like the collapsed menu gets focus briefly, screen elements flash but the focus remains outside the menu.
Has anyone else encountered this issue?
In a TabView with the .sidebarAdaptable style, including TabSection elements prevents the default back swipe on the remote from revealing the sidebar. Removing all TabSection elements and using only Tab elements makes it work as expected:
import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } }
Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } }
Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } }
Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } }
Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } }
Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } }
Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } }
Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } }
Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } }
TabSection("Section") {
Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } }
Tab("Tab", systemImage: "square.fill") { Button(action: {}) { Text("Button") } }
}
}.tabViewStyle(.sidebarAdaptable)
}
}
Am I using it wrong, or is this a bug?
SWIFTUI - update an Array/property Element gives error (had to replace the Whole structure), not sure my syntax is correct
and Gives Syntax error..
Cannot assign value of type 'Double' to type 'Binding' , snippet of code below
BTW, I was able to use
AllObjects.Replace (but it is process intensive & hanges )
.. replaceSubrange(index...index, with:
[TestObjects(..
latitude:Double(-999.0)
//... etc
)]
Perhaps My syntax has issue .. please help
//code snippets
//declaration
@State private var AllObjects:[TestObjects] = []
func TestObjUpdateLoc(index:Int32) {
AllObjects.TestObjects[index].latitude = Double(-999.0)
**//error ..Cannot assign value of type 'Double' to type 'Binding' **
}
// TestObjects
struct TestObjects: Codable, Hashable {
let seq_id:Int32
let latitude:Double
let longitude:Double
// Many more...
}
I have found a system bug with UINavigationController, UIGestureRecognizerDelegate mainly the swipe back control.
I have reproduced this in many apps, while some that use custom swipe back i can not reproduce, however any app using default uikit/swift transitions i can reproduce the flicker/previous screen flashing
The Bug: a slight tap or series of quick taps anywhere on the screen (with the slightest (1-2pt -x)confuse the system into thinking its a swipe back gesture, however instead of pushing back to previous screen the UI flickers and flashes the previous screen. for a split second, very easy to reproduce.
on screens with lots of options of boxes to tap it happens quite often.
I have removed all custom "swipe back from anywhere" logic, all custom gesture logic, and can still reproduce by tapping the edge of the screen
with only UINavigationController, UIGestureRecognizerDelegate in my navigation controller.
Please let me know the best way to get in contact with someone at apple to either build an extension to prevent this flicker or if a developer has a fix but this is rarely talked about. (velocity limits etc do not work, and just make the gesture feel awful)
all the developers i have reached out too have looked into this and have said "its an ios bug, only fix is build a custom swipe back from anywhere, or wait for apple to fix it).... as a small indie app, building my own seems daunting
Recap: quick or taps with small x movement flash previous screen instead of pushing back or simply recognizing it as a tap and not flashing previous screen. this happens with no custom code default uikit/swift. Link me your app i can probably reproduce it, I have reproduced it in X(was hard), Retro(easy), and many more.
The goal is to have a smooth native swipe/drag back from anywhere gesture while preventing flicking on fast taps or short taps with minor x movement. i have tried everything from setting limits to -x, velocity limits etc. nothing fixes this.
happy hacking!
PS i hope someone at apple calls me and i can explain this and we can fix it for every app in an update.