Posts

Post not yet marked as solved
2 Replies
708 Views
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?
Posted Last updated
.
Post marked as solved
3 Replies
2.1k Views
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
Posted Last updated
.
Post marked as solved
3 Replies
1.1k Views
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?
Posted Last updated
.
Post not yet marked as solved
1 Replies
679 Views
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?
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.1k Views
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?
Posted Last updated
.
Post not yet marked as solved
2 Replies
922 Views
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
Posted Last updated
.
Post not yet marked as solved
1 Replies
526 Views
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.
Posted Last updated
.
Post not yet marked as solved
0 Replies
713 Views
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?
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.1k Views
Using XCode Beta 3 and the simulator, I have a ScrollView (with a ForEach generating the items) with a button in a View inside that view. It does not seem to get any user interaction.This used to be a List but could not stop the Cells from getting the tap (so I thought that the Button was blocked from UI interaction). Now, with the Button in the ScrollView still does not react and I am wondering if I have the base Button code working.My code looks like: Button(action: { self.tappedExtendArticle() }) { Image(systemName: "text.append").font(.subheadline) } func tappedExtendArticle() { self.extendArticleHandler?() }I am not seeing any calls to 'tappedExtendArticle'. Is there something wrong in my Button code?
Posted Last updated
.
Post not yet marked as solved
0 Replies
500 Views
I'm trying to implement a 'pull up to add' to a list. Kinda like 'pull down to refresh'. I have added a DragGesture to the List. But I only get a single callback to 'onChange()' and I cannot figure out how to implement 'updating()' Anyone have any success in using 'updating()' to track a scroll view position/state?
Posted Last updated
.
Post not yet marked as solved
0 Replies
515 Views
I am updating my app from beta2 to beta3. Looks like the old format for creating a popover has been replaced with a new mechanism.My goal is to create the 'ellipses' menu item for my app.My old SwiftUI code looked like:struct MenuButton : View { @State var showMenu: Bool = false var body: some View { Button(action: { self.showMenu = true }) { Image(systemName: "ellipsis") } .presentation(showMenu ? Popover(content: MenuView(isMenuPresented: $showMenu), dismissHandler: { self.showMenu = false }) : nil) }}But the .presentation(...) code was marked as removed. So, I moved to a new format, that seems appropriate, .popOver(...)struct MenuButton : View { @State var showMenu: Bool = false var body: some View { Button(action: { self.menuButtonTapped() }) { Image(systemName: "ellipsis") } .popover(isPresented: $showMenu) { MenuView(isMenuPresented: self.$showMenu) } // FIXME: Need to compute the attachmentAnchor point, but I'm not clear how to // do that in Beta3. } func menuButtonTapped() { self.showMenu = true }}You can see I am stuck trying to compute the 'attachmentAnchor' point as an argument for the popover. Anyone know how to compute the attachment point for the button. I don't see how to get the location of the button. Thanks in advance,Charlie
Posted Last updated
.
Post not yet marked as solved
0 Replies
527 Views
I am trying to use SwiftUI for an iPad app and want to include a button (ellipsis) to access a menu.I have a Button, displaying the Image(systemName: "ellipsis"). I am trying to understand how to display a new View as a popover tied to the pressed button.To use Popover, I need a target point, but I don't see how to gain access to this under SwiftUI. Anyone have any clues on this?
Posted Last updated
.