I am working on an iPadOS app that is fully SwiftUI (iOS14.0 beta1).
I am using a .popover(Menu()) to present a list of draggable elements to drag back into the main content view. But I cannot get this to work.
I set a .onDrag() on each draggable element.
If, in the onDrag(), I do not dismiss the popover ($isDisplayed = false), then the drag item cannot find anyplace to allow the drag to target. I think that this is from the popover being modal and blocking other views.
If I dismiss the popover, then a long-press to start the drag will also generally lose the item to drag. I can only maintain the drag with very specific actions being moving just as the long press turns the item into draggable element.
Any ideas on what I am doing wrong?
Post
Replies
Boosts
Views
Activity
I am writing a document-based app using the new SwiftUI 'App' protocol. I have a '+' button that reveals a popover. Within the popover, I have a List of buttons.
When rendering this, the simulator shows a very small rectangle and *none* of the buttons. If I change this to a VStack and ForEach, I get a set of buttons.
Is there something I am doing wrong to render a List in the Popover? I want to use the List for the separators and the 'grouped' formatting of the List view for more polish finish.
Any suggestions on how to get this to work?
import SwiftUI
enum DragAction: String {
case addEntry = "addEntry"
case addTask = "addTask"
case addAttachment = "addAttachment"
}
struct MenuItem: Identifiable {
var id = UUID()
let name: String
let iconName: String
let dragAction: DragAction
}
struct PlusPopoverMenu: View {
@Binding var isPresented: Bool
let menuItems: [MenuItem] = [
MenuItem(name: "Add Entry", iconName: "pencil.and.outline", dragAction: .addEntry),
MenuItem(name: "Add Task", iconName: "checkmark.square", dragAction: .addTask),
MenuItem(name: "Add Attachment", iconName: "rectangle.and.paperclip", dragAction: .addAttachment),
]
var body: some View {
VStack(alignment: .leading) {
ForEach(menuItems) { item in
HStack {
Text(item.name)
Spacer()
Image(systemName: item.iconName)
}
.padding(12.0)
.background(Color(UIColor.systemBackground))
.onDrag {
isPresented = false
return NSItemProvider(object: item.dragAction.rawValue as NSString) }
}
}
.listStyle(InsetGroupedListStyle())
.padding(16.0)
.background(Color(UIColor.systemGroupedBackground))
/* THis is broken in beta 1
List(menuItems) { item in
HStack {
Text(item.name)
Spacer()
Image(systemName: item.iconName)
}
.onDrag {
isPresented = false
return NSItemProvider(object: item.dragAction.rawValue as NSString) }
}
.listStyle(InsetGroupedListStyle())
.padding(16.0)
*/
}
}
Example popovermenu struct - https://developer.apple.com/forums/content/attachment/a1d4fc9b-d3b8-43a6-aa4f-b965cc7a88af
I am writing a SwiftUI application, using DocumentGroup. The document UTI I need to use conforms to 'com.apple.package' not 'public.data' since it is a directory of files.
If the exported Filetype conforms to 'public.data, public.content', the DocumentGroup creates a file and passes it to me (and ends up with the name 'Untitled.hawk' (hawk is my extension).
If I change the exported FileType of 'com.apple.package', I get an error and my Document type is never instantiated.
I see the same issue on both the simulator and an iPad.
The error is:
2020-07-20 17:06:27.339598-0400 HawkMultiPlatformMockup[19622:2242164] [DocumentManager] Cannot create urlWrapper for url file:///private/var/mobile/Containers/Data/Application/5F0B4A8E-E9AB-491B-A1B2-30FC88198B91/tmp/Untitled.hawk/. error Error Domain=NSPOSIXErrorDomain Code=20 "couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/private/var/mobile/Containers/Data/Application/5F0B4A8E-E9AB-491B-A1B2-30FC88198B91/tmp/Untitled.hawk': Not a directory" UserInfo={NSDescription=couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/private/var/mobile/Containers/Data/Application/5F0B4A8E-E9AB-491B-A1B2-30FC88198B91/tmp/Untitled.hawk': Not a directory}.
Any ideas how to get this to work?
I am working on an app that supports PencilKit. I want to add a '+' to the ToolPicker like Preview does to add in a custom action using the pencil. Is this possible with the current UI?
I am working on a document based app in SwiftUI, using the approach outlined in wwdc20-10039.
I have a DocumentGroup and an editor. All works pretty well.
However, when I launch the app, sometimes it starts with 'Recents' selected and the code shows a spinner. This never completes.
Two questions:
Is this a bug in beta1 to never complete the search in recents?
What do I need to do to get something in the 'recents' folder (or is it all 'automatic'?)
What controls if the app opens to this view or the normal file picker view?
I am building a DocumentGroup-based app and want to use the iPad behavior for its containing NavigationView.
I need to keep the functionality "<" from the navigation view provided by the Document Group to allow the user to move between files. At the same time, I need to support the 'sidebar' behaviors in the main app for the user to navigate between components of the app.
Any ideas on how to do this?
An image of this (with annotation) is at: GitHub at /cwoloszynski/appleforums/master/Document%20Navbar%20Issue.png
Does anyone know if Apple intends to deprecate PKDrawingReference in iOS14? It seems to be missing from the betas, but I cannot find any notes that say it is being intentionally removed.
I am trying to support undo between file opening in my app. So, when I restore a drawing, I attempt to also restore the undo actions. I was hoping that they would restore into the ToolPicker so the user could see the undo arrows there and use them 'just where they left off'.
Does anyone know if there is a way to do this? Injecting them into the undoManager from @Environment(\.undoManager) certainly does not appear to work.
Thoughts?