|
I tried a variety of ways to get the EditButton to be added to the Navigation Bar and it would never render correctly (adding it as the leading by itself, trailing by itself, added as leading with leading & trailing properties, and added as trailing with leading & trailing properties). It is shown, but when you tap it the UI just flitters and the button title changes to "Done" but you never see the delete circles to the left of the rows. Is anyone else seeing this?
|
|
1- Did you try swiping the row to see if it triggers the delete option? 2- If yes, and the problem persists. Could you reformat the code section so all of it shows? including all functions being called? |
|
MarcusKay, I am able to swipe and delete, and the Edit/Done button still doesn't show. I updated my code above to include all of the structs and class. Let me know if you need anything else. Thank you for taking a look at this. :) |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates. Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
The issue is in declaring 2 separate This is a great example of how usually it's the simple things that we miss. I should have caught it the first time. That's why whenever there's an issue I can't find, I look at everything from the top. 😉 So your leading and trailing buttons should be this:
Always remember the order of modifiers matters. So if you want both leading and trailing, they have to be on the same modifier. |
|
MarcusKay, Did you run that and it worked? Made the updated you suggested, which I thought I had tried, and it still doesn't work right (e.g. the Edit button changes to Done, but no red delete dots appear on the left).
|
|
Yes, I copy-pasted your code, changed it and it worked. Here's your content view struct:
|
|
I just tried it on iPod Touch (7th generation) and it didn't work... when I tried on others it didn't work either until I did Clean Build Folder. It then worked on all simulators. Might be a simulator / Xcode bug. |
|
I think I'm seeing similar behavior. If I add an expense and then tap Edit the red circles do not show up, but Edit does change to Done in the NavBar. Then if I swipe on any item to expose the row's delete option on the far right side, and then either commit the delete or cancel out of it, then tap edit the delete circles show up. If I force quit the app and then relaunch it and then immediately hit Edit it behavies as expected. Does this match what you're seeing? I'm testing on device with an iPhone 12 Pro Max running iOS 14.3 and using Xcode 12.3. |
|
Change the
I think it is to do with |
|
Could be an issue that crept up with iOS 14? I've tried to use the new
|
|
I got around this by using a CodingKey enum after finding this Stack Overflow question – including the following code in the
|
|
I am finding it works perfectly when you first run it. Then if you add a new item and dismiss the sheet, the label toggles between Edit and Done and the list bounces sideways. If you then swipe an item sideways to reveal the delete button and then swipe it back, the Edit button starts functioning normally again, putting the list into edit mode and showing the red circle - buttons again! |
|
I've got exactly the same problem here - even when adding the add and edit buttons in the same method, the edit button does not work properly; you can startle it into getting its act together by starting and cancelling a 'swipe- delete' of an item, but it certainly does not work as intended. Bumping this up in case anyone has found a solution... |
|
If you look up navigationBarItems in apple's documentation, it shows that it is deprecated now, and that you should be using toolbar instead. I think that might have something to do with the problems that you are running into with this project. Although, I don't know enough about it to say for certain. https://developer.apple.com/documentation/swiftui/view/navigationbaritems(leading:) I can't get that link to work in this forum for some reason, but if you copy and paste it into your browser it should work. |
|
Link to Apple documentation for NavigationBarItems (deprecated) It may help you to know that when adding the link the text goes between the square brackets |
|
I'm finding it works perfectly when you first run it. Then if you add a new item and dismiss the sheet, the label toggles between Edit and Done and the list bounces sideways. If you then swipe an item sideways to reveal the delete button and then swipe it back, the Edit button starts functioning normally again, putting the list into edit mode and showing the red circle - buttons again, I hope this guide will help you! |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.