Posts

Post not yet marked as solved
0 Replies
80 Views
Is it possible under macOS to drag a file from an app into the Finder?  For example, I want to drag a CSV file from the app to the Finder, but the following code does not work. static var transferRepresentation: some TransferRepresentation {         FileRepresentation(exportedContentType: .commaSeparatedText) {_ in             SentTransferredFile(Bundle.main.url(forResource: "Demo", withExtension: "csv")!)         } } And I changed the exportedContentType to ".fileUrl", ".url" and ".data" but the code still does not work.
Posted Last updated
.
Post not yet marked as solved
0 Replies
53 Views
It works on Monterey, but not work on Ventura. struct ContentView: View { @FocusState private var focus: FocusableElement? @FocusedValue(\.focusedElement) var focusElement var body: some View { VStack(spacing: 30) { HStack { GroupBox { Circle() .focusable() .focused($focus, equals: .circle) .focusedValue(\.focusedElement, .circle) .frame(width: 100, height: 100) .padding() Text(focus == .circle ? "Selected" : "Not selected") } .onTapGesture { focus = .circle } GroupBox { Rectangle() .focusable() .focused($focus, equals: .rectangle) .focusedValue(\.focusedElement, .rectangle) .frame(width: 100, height: 100) .padding() Text(focus == .rectangle ? "Selected" : "Not selected") } } .onTapGesture { focus = .rectangle } Text("Focused Element: \(focusElement?.rawValue ?? "None")") } .padding() .frame(width: 500, height: 300) } } enum FocusableElement: Equatable, Hashable { case rectangle case circle } enum Selection: String, Hashable { case none case rectangle case circle } extension FocusedValues { struct FocusedElement: FocusedValueKey { typealias Value = Selection } var focusedElement: FocusedElement.Value? { get { self[FocusedElement.self] } set { self[FocusedElement.self] = newValue } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
Posted Last updated
.
Post not yet marked as solved
0 Replies
91 Views
.commandsRemoved() does not work for the Window and WindowGroup scenes if it’s the primary group (first one). Then I tried to add new menu using the code .commands {       CommandGroup(replacing: .newItem) {           Button("New Document") {               newDocument { TestDocument() }           }           .keyboardShortcut("n") } But app crashed with error " Expected subclass override" The test app is a document-based app, with a welcome window using the new Window scene.
Posted Last updated
.
Post not yet marked as solved
2 Replies
5.7k Views
I created a new iOS project targeting iOS 15 using Xcode 13.0 beta (13A5154h) on Big Sur to test some new SwiftUI features.  Xcode shows me the error like "*** is only available in iOS 15.0 or newer" for all new API for iOS 15.  The project target is iOS 15  I tried to create another project again, same problem.  Would you please help to fix it?  Thanks a lot! Philipp
Posted Last updated
.
Post not yet marked as solved
1 Replies
577 Views
By default, the events (mouse/cursor/scroll...) are bypassed to the controls under the NSView, for example, there are one NSView (named A) and one NSTextField (named B). A and B are at same place, and A is above B.All mouse events passed to B (TextField)Cursor has been changed as "I", not the default cursor as expectedScroll mouse will scroll B (the textfield if multiple lines)I'd like that if mouse on A (the NSView), all the events are not passed to B. So I subclass NSView for A as the code following:// ------------------------------------------------class ResponsibleView: NSView { override func acceptsFirstMouse(theEvent: NSEvent?) -> Bool { return true } override var acceptsFirstResponder : Bool { return true } override func mouseUp(theEvent: NSEvent) { } override func resetCursorRects() { superview?.resetCursorRects() self.addCursorRect(self.bounds, cursor: NSCursor.arrowCursor()) } override func scrollWheel(theEvent: NSEvent) { }}// ------------------------------------------------Now there is a problem on cursor - the cursor is not stable, sometimes the cursor appears correctly, but sometimes incorrect. Would you please help to check following my questions?- Is there simple solution to avoid events bypassing NSView?- Why the cursor is too strange, how to make it be stable?- Why the cocoa for OSX makes things too complicated and not be intuitive? ( I am new for OSX development), is there any modern UI solution for OSX like XAML ...Thanks,
Posted Last updated
.
Post not yet marked as solved
0 Replies
320 Views
I tried to create a menu item with full width of the screen, as following the code: VStack { Menu { Button("Option 1", action: actionOne) Button("Option 2", action: actionTwo)     } label: {          Label("Options", systemImage: "paperplane")                .padding()     } .frame(maxWidth: .infinity) } And tried to change the label using HStack VStack { Menu { Button("Option 1", action: actionOne) Button("Option 2", action: actionTwo)     } label: {          HStack { Text("Options") Spacer() } .padding()     } .frame(maxWidth: .infinity) } And tried to customize using MenuStyle. But the menu label renders NOT in the full width using all preceding the codes. Would you please help to check and share me the solution? Thanks, Philip
Posted Last updated
.
Post not yet marked as solved
3 Replies
591 Views
The keyboard shortcut does not work on the iPadOS 14 simulator using following the code. @main struct DemoApp: App {     var body: some Scene {         WindowGroup {             Text("Demo Keyboard Shotcuts")         }         .commands {             CommandGroup(before: .sidebar) {                 Button("Test Keyboard", action: { print("keyboard shortcut - command + k") })                     .keyboardShortcut("[")             }         }     } } Would you please help us to know what's the problem? From the WWDC session "What's new in SwiftUI", the keyboard shortcut should work on iPad. Thank you.
Posted Last updated
.
Post not yet marked as solved
1 Replies
316 Views
We need to show a welcome window before creating a new document (or by the choose of the user to create a new document). Would you mind sharing us an example for how to show a welcome window (not a document window) when the app start?
Posted Last updated
.
Post marked as solved
3 Replies
1.8k Views
We believe it's time to start developing apps using SwiftUI by watched the WWDC20 "Keynote" and "Platforms State of the Union". We are planning to develop an app for the iOS and macOS, and we'd like to macOS app to be fine tuned to use the macOS native capabilities. I am wondering what's the recommend way that @Apple prefer to do for the new app using SwiftUI for developing the macOS app, catalyst or native? (sharing code is not the key, we can copy :) ) Thank you.
Posted Last updated
.
Post not yet marked as solved
1 Replies
887 Views
Hello,My app supports to open file via UIDocumentPickerViewController, and the app needs to detect if the opened file is writable.We are using the "isWritableFileAtPath" method to detect if the file is writable, but iCloud Drive behaviors strangly:----Case one:Sharing a file directly with readonly permission from iCloud account A to iCloud account B, "isWritableFileAtPath" return "false" on the device of the B user - that's what we expected.----Case two:Sharing a FOLD with readonly permission from iCloud account A to iCloud account B, "isWritableFileAtPath" for a file in the shared folder returns "true" on the device of the B user - that's NOT what we expected.=============Would you please help us on it?- Is it a bug of the iCloud Drive?- Or if there is another way to detect if the app has permission to write the file opened using UIDocumentPickerViewController ?Thanks,Philip
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.5k Views
Hello,I have sent an app to Apple notary service about one day, but the app status is still in processing status. Before it just taken minutes to get the app finish the notarizing. There was no error message when uploading the app to notary service. I am not sure if there is way to check if Apple notary service works or to if there is way report the issue to Apple. Could you please help on it? Thanks, Philip
Posted Last updated
.
Post not yet marked as solved
0 Replies
459 Views
Hello,ABAddressBook.shared() works well on macOS 10.13.x, but return nil on macOS 10.14 (Mojave). Could you please help on the solution? Thanks, Philip
Posted Last updated
.
Post marked as solved
9 Replies
3.2k Views
Problem: The Widget Simulator does not support the dark mode correctlyDescription: I created a simple today widget to display just one label with the default text color (label color), and tested the widget using the "Widget Simulator", the text color is always black color no matter the system appearance is. (There is no problem for the main app to display correctly content in dark mode)And even the text "Show Less..." and "Show More ..." in the widget always display in black colorEnvironment: XCode Beta 6 Mojave Beta 10Would you please help to suggest to actions to fix it? Philip
Posted Last updated
.