Provide views, controls, and layout structures for declaring your app's user interface using SwiftUI.

Posts under SwiftUI tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

iOS DisclosureGroup content clipping
I have a SwiftUI page that I want to simplify by showing basic information by default, and putting the additional info behind a "Details" DisclosureGroup for advanced users. I started by laying out all the components and breaking things into individual Views. These all are laid out and look fine. Then I took several of them and added them inside a DisclosureGroupView. But all of a sudden, the views inside started getting crunched together and the contents of the DisclosureGroup got clipped about 2/3 of the way down the page. The problem I'm trying to solve is how to show everything inside the DIsclosureGroup. The top-level View looks like this: VStack { FirstItemView() SecondView() DetailView() // <- Shows disclosure arrow } Where DetailView is: struct DetailView: View { @State var isExpanded = true var body: some View { GeometryReader { geometry in DisclosureGroup("Details", isExpanded: $isExpanded) { ThirdRowView() Spacer() FourthRowView() VStack { FifthRowWithChartView() CaptionLabelView(label: "Third", iconName: "chart.bar.xaxis") } } } } } The FifthRowWithChartView is half-clipped. One thing that might contribute is that there is a Chart view at the bottom of this page. I've tried setting the width and height of the DisclosureGroup based on the height returned by the GeometryReader, but that didn't do anything. This is all on iOS 17.6, testing on an iPhone 15ProMax. Any tips or tricks are most appreciated.
2
0
219
3w
Help, can't use TabView
Hi, I learned swift only a few weeks ago, and im trying to make a TabView in Xcode. But, it shows only one item! I've already made this work in other apps, but I can't get it working here! import SwiftUI struct tabs: View { var body: some View { TabView { ContentView() .tabItem { Image(systemName: "house.circle.fill") Text("Home") Settngs() .tabItem { Image(systemName:"gear.circle.fill") Text("Settings") } } } } } #Preview { tabs() } and also, I checked "settngs()" and its my name
1
0
197
3w
VisionOS NavigationStack background cannot be removed?
I have a simple example to demonstrate... struct MyView: View { var body: some View { Text("WOW") } } struct MyOtherView: View { var body: some View { NavigationStack { Text("WOW") } } } On VisionOS, MyOtherView has a glass background effect that cannot be disabled. glassBackgroundEffect(displayMode: .never) .background(.clear), .foregroundColor(.clear), none of them work. I then resorted to the SwiftUIIntrospect package to try set .clear on various child objects of the NavigationStack but nothing is working. I am in control of my own glass containers. I have a couple with space between them, but with the NavigationStack it sets a background behind both of them ruining the effect. This is what MyOtherView renders as: I'm looking for it to be completely transparent except the text. Like the below layout. For now I will have to roll my own navigation.
2
2
354
3w
UI Tab Bar
Anyone else get these warnings when using UI Tab Bar in visionOS? Are these detrimental to pushing my visionOS app to the App Review Team? import SwiftUI import UIKit struct HomeScreenWrapper: UIViewControllerRepresentable { func makeUIViewController(context: Context) -> UITabBarController { let tabBarController = UITabBarController() // Home View Controller let homeVC = UIHostingController(rootView: HomeScreen()) homeVC.tabBarItem = UITabBarItem(title: "Home", image: UIImage(systemName: "house"), tag: 0) // Brands View Controller let brandsVC = UIHostingController(rootView: BrandSelection()) brandsVC.tabBarItem = UITabBarItem(title: "Brands", image: UIImage(systemName: "bag"), tag: 1) tabBarController.viewControllers = [homeVC, brandsVC] return tabBarController } func updateUIViewController(_ uiViewController: UITabBarController, context: Context) { // Update the UI if needed } } struct HomeScreenWrapper_Previews: PreviewProvider { static var previews: some View { HomeScreenWrapper() } }
1
0
226
3w
SwiftData make my app very slow
Hello, I have been working on SwiftData since a month now and i found very weird that every time i update a data inside a SwiftData model my app became very slow. I used the instrument if something was wrong, and i see memory increasing without releasing. My app have a list with check and unchecked elements (screeshot below). I just press check and unchecked 15 times and my memory start from 149mb to 361mb (screenshots below). For the code i have this model. final class Milestone: Identifiable { // ********************************************************************* // MARK: - Properties @Transient var id = UUID() @Attribute(.unique) var uuid: UUID var text: String var goalId: UUID var isFinish: Bool var createdAt: Date var updatedAt: Date var goal: Goal? init(from todoTaskResponse: TodoTaskResponse) { self.uuid = todoTaskResponse.id self.text = todoTaskResponse.text self.goalId = todoTaskResponse.goalId self.isFinish = todoTaskResponse.isFinish self.createdAt = todoTaskResponse.createdAt self.updatedAt = todoTaskResponse.updatedAt } init(uuid: UUID, text: String, goalId: UUID, isFinish: Bool, createdAt: Date, updatedAt: Date, goal: Goal? = nil) { self.uuid = uuid self.text = text self.goalId = goalId self.isFinish = isFinish self.createdAt = createdAt self.updatedAt = updatedAt self.goal = goal } } For the list i have var milestonesView: some View { ForEach(milestones) { milestone in MilestoneRowView(task: milestone) { milestone.isFinish.toggle() } .listRowBackground(Color.backgroundComponent) } .onDelete(perform: deleteMilestone) } And this is the cell struct MilestoneRowView: View { // ********************************************************************* // MARK: - Properties var task: Milestone var action: () -> Void init(task: Milestone, action: @escaping () -> Void) { self.task = task self.action = action } var body: some View { Button { action() } label: { HStack(alignment: .center, spacing: 8) { Image(systemName: task.isFinish ? "checkmark.circle.fill" : "circle") .font(.title2) .padding(3) .contentShape(.rect) .foregroundStyle(task.isFinish ? .gray : .primary) .contentTransition(.symbolEffect(.replace)) Text(task.text) .strikethrough(task.isFinish) .foregroundStyle(task.isFinish ? .gray : .primary) } .foregroundStyle(Color.backgroundComponent) } .animation(.snappy, value: task.isFinish) } } Does someone have a idea? Thanks
1
0
454
3w
Inconsistency on view lifecycle events between UIKit and SwiftUI when using UIVPageViewController
Overview I've found inconsistency on view lifecycle events between UIKit and SwiftUI as the following shows when using UIVPageViewController and UIHostingController as one of its pages. SwiftUI View onAppear is only called at the first time to display and never called in the other cases. UIViewController viewDidAppear is not called at the first time to display, but it's called when the page view controller changes its page displayed. The whole view structure is as follows: UIViewController (root) UIPageViewController (as its container view) UIHostingController (as its page) SwiftUI View (as its content view) UIViewControllerRepresentable (as a part of its body) UIViewController (as its content) Environment Xcode Version 15.4 (15F31d) iPhone 15 Pro (iOS 17.5) (Simulator) iPhone 8 (iOS 15.0) (Simulator) Sample code import UIKit import SwiftUI class ViewController: UIViewController, UIPageViewControllerDelegate, UIPageViewControllerDataSource { private var pageViewController: UIPageViewController! private var viewControllers: [UIViewController] = [] override func viewDidLoad() { super.viewDidLoad() setup() } private func setup() { pageViewController.delegate = self pageViewController.dataSource = self let page1 = UIHostingController(rootView: MainPageView()) let page2 = UIViewController() page2.view.backgroundColor = .systemBlue let page3 = UIViewController() page3.view.backgroundColor = .systemGreen viewControllers = [page1, page2, page3] pageViewController.setViewControllers([page1], direction: .forward, animated: false) } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { super.prepare(for: segue, sender: sender) guard let pageViewController = segue.destination as? UIPageViewController else { return } self.pageViewController = pageViewController } func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) { print("debug: \(#function)") } func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? { print("debug: \(#function)") guard let viewControllerIndex = viewControllers.firstIndex(of: viewController) else { return nil } let previousIndex = viewControllerIndex - 1 guard previousIndex >= 0, viewControllers.count > previousIndex else { return nil } return viewControllers[previousIndex] } func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? { print("debug: \(#function)") guard let viewControllerIndex = viewControllers.firstIndex(of: viewController) else { return nil } let nextIndex = viewControllerIndex + 1 guard viewControllers.count != nextIndex, viewControllers.count > nextIndex else { return nil } return viewControllers[nextIndex] } } struct MainPageView: View { var body: some View { VStack(spacing: 0) { PageContentView() PageFooterView() } .onAppear { print("debug: \(type(of: Self.self)) onAppear") } .onDisappear { print("debug: \(type(of: Self.self)) onDisappear") } } } struct PageFooterView: View { var body: some View { Text("PageFooterView") .padding() .frame(maxWidth: .infinity) .background(Color.blue) .onAppear { print("debug: \(type(of: Self.self)) onAppear") } .onDisappear { print("debug: \(type(of: Self.self)) onDisappear") } } } struct PageContentView: UIViewControllerRepresentable { func makeUIViewController(context: Context) -> some UIViewController { PageContentViewController() } func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {} } class PageContentViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() setup() } private func setup() { view.backgroundColor = .systemYellow let label = UILabel() label.text = "PageContentViewController" label.font = .preferredFont(forTextStyle: .title1) view.addSubview(label) label.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ label.centerXAnchor.constraint(equalTo: view.centerXAnchor), label.centerYAnchor.constraint(equalTo: view.centerYAnchor) ]) } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) print("debug: \(type(of: Self.self)) \(#function)") } override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) print("debug: \(type(of: Self.self)) \(#function)") } } Logs // Display the views debug: MainPageView.Type onAppear debug: PageFooterView.Type onAppear // Swipe to the next page debug: pageViewController(_:viewControllerAfter:) debug: pageViewController(_:viewControllerBefore:) debug: PageContentViewController.Type viewDidDisappear(_:) debug: pageViewController(_:didFinishAnimating:previousViewControllers:transitionCompleted:) debug: pageViewController(_:viewControllerAfter:) // Swipe to the previous page debug: PageContentViewController.Type viewDidAppear(_:) debug: pageViewController(_:didFinishAnimating:previousViewControllers:transitionCompleted:) debug: pageViewController(_:viewControllerBefore:) As you can see here, onAppear is only called at the first time to display but never called in the other cases while viewDidAppear is the other way around.
0
0
142
3w
NO ANIMATIONS in NavigationStack or NavigationSplitView
I'm building a macOS app using SwiftUI and I recently updated to xcode 14.3. Since then I've been debugging why none of my animations were working, it turned out that the NavigationSplitView or NavigationStack are somehow interfering with all the animations from withAnimation to .transition() and everything in between. Is anyone else experiencing this, knows a work around or knows why this is happening?
9
8
5.5k
3w
SF Symbol image color in the menu bar
I can set color of the SF symbol image in the application window but cannot do the same in the menu bar. I wonder how I can change the color in the menu? import SwiftUI @main struct ipmenuApp: App { var body: some Scene { MenuBarExtra { Image(systemName: "bookmark.circle.fill") .renderingMode(.original) .foregroundStyle(.red) } label: { Image(systemName: "bookmark.circle.fill") .renderingMode(.original) .foregroundStyle(.red) } } } xcodebuild -version Xcode 15.0 Build version 15A240d
4
1
798
3w
Draggable Views with Child Drop Destination Elements not Draggable in iOS 18
I'm creating an app that has a number of draggable views, and each of these views themselves contain child dropDestination views. In iOS 17.x they are draggable as expected. However, in iOS 18 betas 1 & 2 a long press on these views does NOT pick them up (start the drag operation). I have not tested with macOS 15 betas but the issue may well exist there also. Is this a bug in iOS 18 betas 1 & 2 or does the implementation need to be updated somehow for iOS 18? Please see example code below: Views: import SwiftUI extension View { func dropTarget<T>(for payloadType: T.Type, withTitle title: String) -> some View where T: Transferable { modifier(DropTargetViewModifer<T>(title: title)) } } struct DropTargetViewModifer<T>: ViewModifier where T: Transferable { let title: String func body(content: Content) -> some View { content .dropDestination(for: T.self) { items, location in print("Item(s) dropped in \(title)") return true } isTargeted: { targted in if targted { print("\(title) targeted") } } } } struct InnerTestView: View { let title: String let borderColor: Color var body: some View { ZStack { Text(title) .padding() Rectangle() .stroke(borderColor) } .contentShape(Rectangle()) } } struct TestView: View { var body: some View { VStack(spacing: 0.0) { HStack(alignment: .top, spacing: 0.0) { InnerTestView(title: "Drop Zone 1", borderColor: .pink) .dropTarget(for: ItemType1.self, withTitle: "Drop Zone 1") InnerTestView(title: "Drop Zone 2", borderColor: .indigo) .dropTarget(for: ItemType2.self, withTitle: "Drop Zone 2") } InnerTestView(title: "Drop Zone 3", borderColor: .orange) .dropTarget(for: ItemType3.self, withTitle: "Drop Zone 3") } .contentShape(Rectangle()) .draggable(ItemType1(id: "Object 1")) } } struct ContentView: View { var body: some View { ScrollView { LazyVStack { TestView() TestView() InnerTestView(title: "Draggable 2", borderColor: .orange) .draggable(ItemType2(id: "Object 2")) InnerTestView(title: "Draggable 3", borderColor: .indigo) .draggable(ItemType3(id: "Object 3")) } .padding() } } } Transfer Representations: import UniformTypeIdentifiers import CoreTransferable extension UTType { static let itemType1 = UTType(exportedAs: "com.droptest.typeone") static let itemType2 = UTType(exportedAs: "com.droptest.typetwo") static let itemType3 = UTType(exportedAs: "com.droptest.typethree") } struct ItemType1: Codable, Transferable { var id: String public static var transferRepresentation: some TransferRepresentation { CodableRepresentation(contentType: .itemType1) } } struct ItemType2: Codable, Transferable { var id: String public static var transferRepresentation: some TransferRepresentation { CodableRepresentation(contentType: .itemType2) } } struct ItemType3: Codable, Transferable { var id: String public static var transferRepresentation: some TransferRepresentation { CodableRepresentation(contentType: .itemType3) } }
3
2
212
3w
CloudKit Stopped Syncing after adding new Entities
Can someone please shed some light? I have an app that uses Core Data and CloudKit, up until the last version, I was able to sync data between devices but now after I added two new Entities for some reason it stopped syncing between devices. Here is how I did the change: Created a new Core Data container. Added the new Entities and their Attributes Tested the new Entities locally to be able to send the new schema to CloudKit. Went to CloudKit and made sure that the new Entities and Attributes were reflected on the Developent database. Deploy Schema Cahnges. Went to the Production database to make sure the new schema was deployed; and it was, both databases look the same. Testing: Tested in the simulator and with a real device and everything syncs, even the new Entities. If I download the app from the App Store on two different devices they do NOT sync. Based on the procedure I'm describing above, is there any important step I may have missed when doing the migration? I'm not sure if this is related to the syncing issue but after testing a few times, I no longer can turn the iCloud on, I get the following message when I try to turn iCloud Sync On. CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate resetAfterError:andKeepContainer:]: <NSCloudKitMirroringDelegate: 0x282c488c0> - resetting internal state after error: Error Domain=NSCocoaErrorDomain Code=134410 "CloudKit setup failed because there is another instance of this persistent store actively syncing with CloudKit in this process." UserInfo={NSURL=file:///var/mobile/Containers/Data/Application/73F19BC7-4538-4098-85C7-484B36192CF3/Library/Application%20Support/CoreDataContainer.sqlite, NSLocalizedFailureReason=CloudKit setup failed because there is another instance of this persistent store actively syncing with CloudKit in this process., NSUnderlyingException=Illegal attempt to register a second handler for activity identifier com.apple.coredata.cloudkit.activity.setup.8D4C04F6-8040-445A-9447-E5646484521} Any idea of what could be wrong and preventing the devices from syncing? Any idea or suggestion is welcome. Thanks
3
0
1.9k
3w
What is the info property of SwiftUI::Layer
What is the info property of SwiftUI::Layer? I couldn't find any document or resource about it. It appears in SwiftUI::Layer's definition: struct Layer { metal::texture2d<half> tex; float2 info[5]; /// Samples the layer at `p`, in user-space coordinates, /// interpolating linearly between pixel values. Returns an RGBA /// pixel value, with color components premultipled by alpha (i.e. /// [R*A, G*A, B*A, A]), in the layer's working color space. half4 sample(float2 p) const { p = metal::fma(p.x, info[0], metal::fma(p.y, info[1], info[2])); p = metal::clamp(p, info[3], info[4]); return tex.sample(metal::sampler(metal::filter::linear), p); } };
0
1
267
3w
Color asset test not working due to color not being loaded when test conditions are evaluated
I've written a Swift package plugin to add the colours provided in the asset bundles in an extension of the SwiftUI Color type but I'm having difficulties testing this since the bundle and/or colour that is in the asset catalogs are not yet loaded when XCTest goes to evaluate the test conditions. Here is my test code: (colours are just random colours, some derive from macOS colour picker; also, the new static method is functionality that I added and is not present in the existing Color APIs) final class TestCase: XCTestCase { func testBanana() { XCTAssertEqual(Color.banana, Color.new(from: "FEFC78")!) } func testAlexsColor() { XCTAssertEqual(Color.alexsColor, Color.new(from: "0432FF")!) } func testMaximumPowerColor() { XCTAssertEqual(Color.maximumPower, Color.new(from: "FF2600")!) } func testLongNameColor() { XCTAssertEqual(Color.reallyLongNameThatJustKeepsGoingOnAndOnAndOnAndOn, Color.new(from: "AAA000")) } } Here is an example error message that I get when I run the test: testBanana(): XCTAssertEqual failed: ("NamedColor(name: "Banana", bundle: Optional(NSBundle &lt;/Users/trevorhafner/Library/Developer/Xcode/DerivedData/TransportBase-cbagdabrompfzofwkimswvlsincu/Build/Products/Debug/TransportBaseTests.xctest/Contents/Resources/TransportBase_TransportBaseTests.bundle&gt; (not yet loaded)))") is not equal to ("#FEFC78FF") Here is the autogenerated code that my Swift Package Plugin creates: #if canImport(SwiftUI) import SwiftUI import Foundation @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public extension Color { static let banana = Color("Banana", bundle: .module) static let alexsColor = Color("Alex's Color", bundle: .module) static let reallyLongNameThatJustKeepsGoingOnAndOnAndOnAndOn = Color("really long name that just keeps going on and on and on and on", bundle: .module) static let maximumPower = Color("Maximum Power", bundle: .module) } #endif Does anyone know how to somehow instruct the bundle or the Color to load such that the comparison can be made correctly between the two colours?
4
1
1.6k
3w
Question About Weak Self Usage
Hello everyone. I have a small question about Weak Self. In the example below, I am doing a long process to the data I query with SwiftData. (For this reason, I do it in the background.) I don't know if there is a possibility of a memory leak when the view is closed because this process takes a long time. import SwiftUI import SwiftData struct ActiveRegView: View { @Query(filter: #Predicate<Registration> { $0.activeRegistration }, animation: .default) private var regs: [Registration] @Environment(ViewModel.self) private var vm @State private var totalParkingFee: Decimal = 0 var body: some View { ... .onAppear { var totalParkingFee = Decimal() DispatchQueue.global(qos: .userInitiated).async { for reg in regs { totalParkingFee += vm.parkingFee(from: reg.entryRegistration.entryDate, to: .now, category: reg.category, isCustomPrice: reg.isCustomPrice) } DispatchQueue.main.async { withAnimation { totalParkingFee = totalParkingFee } } } } } } I use ViewModel with @Environment, so I don't initilize ViewModel every time view is initilized. I know it's a simple question and I thank you in advance for your answers.
0
0
130
3w
SwiftUI Crashes only on A-Chip device
Hey there, I am currently developing a SwiftUI app for iPad. However, I am currently experiencing a behavior, that I can not explain. My code creates a user-management view. This all works fine if I run it on my iPad Pro with Apple-M-Chip. However, if I try to run the exact same code on an older A-Chip iPad Air (4th Generation), my app crashes. I can recreate this behavior in the simulator on my Mac. When I run it on an iPad Pro Simulator, all works fine. When I run it in an iPad Air (4th Gen) simulator, the app becomes unresponsive. Unfortunatley Xcode does not throw any error that I could use to identify the problem. Currently I solved it with a work-around: As soon as I add a Spacer (even with a with of 0) the code works as expected and the UI is shown. As soon as I remove the Spacer, it crashes again. HStack(alignment: .top){ VStack{ if(data.ui_user.id != -1){ HStack{ Text("Employee-No.:") Spacer() TextField("Employee-No.", value: $data.ui_user.id, format: .number).textFieldStyle(.roundedBorder).disabled(true).containerRelativeFrame(.horizontal, count: 10, span: 3, spacing: 0) } } HStack{ Text("Family Name:") Spacer() TextField("Family Name", text: $data.ui_user.familyName).textFieldStyle(.roundedBorder).containerRelativeFrame(.horizontal, count: 10, span: 3, spacing: 0) } HStack{ Text("Given Name:") Spacer() TextField("Given Name", text: $data.ui_user.givenName).textFieldStyle(.roundedBorder).containerRelativeFrame(.horizontal, count: 10, span: 3, spacing: 0) } HStack{ Text("Role:") Spacer() Picker("Select role", selection: $data.selectedRole){ ForEach(0 ..< self.availableRoles.count, id:\.self){ Text(self.availableRoles[$0].name ?? "???").tag($0) } }.pickerStyle(.menu).containerRelativeFrame(.horizontal, count: 10, span: 3, spacing: 0).background(.drkBlueContainer).cornerRadius(5).foregroundColor(.drkOnBlueContainer).tint(.drkOnBlueContainer) //If I add this spacer, it works. If not, it crashes //Spacer().frame(width: 0.0) }.disabled(noEditAdmin && data.ui_user.id != -1) } Divider() VStack{ HStack{ Text("Created at:") Spacer() TextField("Created at", value: $data.ui_user.createdAt, format: .dateTime).textFieldStyle(.roundedBorder).disabled(true).containerRelativeFrame(.horizontal, count: 10, span: 3, spacing: 0) } HStack{ Toggle("Terminates:", isOn: $data.ui_user.expires) .padding(.trailing, 2.0) } if(data.ui_user.expires){ HStack{ DatePicker("Terminates at:", selection: $data.ui_user.expiresAt, displayedComponents: .date).pickerStyle(.automatic) }} } } If anyone has any ideas, I would be very grateful for a hint :-)
2
0
182
3w
My loop makes a click noise each time it starts
The loop plays smoothly in audacity but when I run it in the device or simulator it clicks each loop at different intensities. I config the session at App level: let audioSession = AVAudioSession.sharedInstance() do { try audioSession.setCategory(.playback, mode: .default, options: [.mixWithOthers]) try audioSession.setActive(true) } catch { print("Setting category session for AVAudioSession Failed") } And then I made my method on my class: func playSound(soundId: Int) { let sound = ModelData.shared.sounds[soundId] if let bundle = Bundle.main.path(forResource: sound.filename, ofType: "flac") { let backgroundMusic = NSURL(fileURLWithPath: bundle) do { audioPlayer = try AVAudioPlayer(contentsOf:backgroundMusic as URL) audioPlayer?.prepareToPlay() audioPlayer?.numberOfLoops = -1 // for infinite times audioPlayer?.play() isPlayingSounds = true } catch { print(error) } } } Does anyone have any clue? Thanks! PS: If I use AVQueuePlayer and repeat the item the click noise disappear (but its no use, because I would need to repeat it indefinitely without wasting memory), if I use AVLooper I get a silence between loops. All with the same sound. Idk :/ PS2: The same happens with ALAC files.
4
2
838
3w
Xcode Accessibility audit in UI Tests gives less than stellar results
I have added a UI test that uses the newish app.performAccessibilityAudit() on each of the screens in my SwiftUI app. I get a handful of test failures for various accessibility issues. Some of them are related to iOS issues (like the "legal" button in a map view doesn't have a big enough tappable are; and, I think, there is a contrast issue with selected tabs in a tab bar, or maybe it is a false positive). Two of the error type I get are around Text elements that use default font styles (like headline) but that apparently get clipped at times and apparently "Dynamic Type font sizes are unsupported". For some of the errors it supplies a screenshot of the whole screen along with an image of the element that is triggering the error. For these text errors it only provides the overall image. After looking at the video I saw that part of the test runs the text size all the way up and I could see that at the largest size or two the text was getting cut off despite using default settings for the frames on all the Text elements. After a bit of trial and error I managed to get the text to wrap properly even at the largest of sizes and most of the related errors went away running on an iPhone simulator. I switched to an iPad simulator and the errors re-appeared even though the video doesn't show the text getting clipped. Does anyone have any tips for actually fixing these issues? Or am I in false positive land here? Also, is there any way to get more specific info out of the test failures? Looking at the entire screen and trying to guess where the issue is kinda sucks.
0
2
377
3w
List Rows Can Be Moved While Not Editing
Hi, I am building a view containing a list of struct objects. I have implemented the onMove to allow the list rows to be moved together with the toolbar EditButton. This works but I have a problem as per title, even when the EditButton is not clicked, i.e., not in editing mode, I still can move the list rows by long pressing the rows. I have searched high and low for a solution but couldn't find one that works perfectly. Below is the code snippet. I am a new iOS dev and really appreciate if someone could help me. Many thanks! @AppStorage("fruits") private var fruits = Fruits.fruits var body: some View { NavigationStack { VStack { List { ForEach(fruits) { fruit in NavigationLink(destination: FruitsView(title: fruit.title)) { fruit.icon Text(fruit.title) } } .onMove { fruits.move(fromOffsets: $0, toOffset: $1) } } .environment(\.defaultMinListRowHeight, UIElementConstants.listCellHeight) } .toolbar { EditButton() } .navigationTitle("Fruits") } } struct Fruits: Identifiable, Codable { var id: UUID var title: String var iconName: String var icon: Image { Image(systemName: self.iconName) } init(id: UUID = UUID(), title: String, iconName: String) { self.id = id self.title = title self.iconName = iconName } } extension Fruits { static let fruits: [Fruits] = [ Fruits( title: "Apple", iconName: "basket.fill"), Fruits( title: "Banana", iconName: "basket.fill"), Fruits( title: "Pineapple", iconName: "basket.fill") ] }
4
1
249
3w