Post

Replies

Boosts

Views

Activity

Reply to Data struct not working
Declare as optional: var orchard: Orchard? to solve first error. Note: photos are great, but code itself is easier to use. For the second, remove the parameter. You can also declare orchard inside ContentView: struct ContentView: View {     @State var orchard: Orchard?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to Cannot convert value of type 'Binding<[Video]>.Type' to expected argument type 'Binding<[Video]>'
You should show more code. NavigationLink(destination: SomeView.init(data: Binding<[Video]> Is it in code ? You need to specify the argument. If you have defined: struct SomeView: View {     @Binding var data: Video Then, in the view with the NavigationLink, you should have: struct ContentView: View {     @State var contentData : Video = // need to give an initial value, as Video(some arg)     var body: some View {         NavigationView {                 NavigationLink(destination: SomeView(data: $contentData)) { or SomeView.init(data: $contentData)                     Text("Press on me with Binding")                 }.buttonStyle(PlainButtonStyle())             }         }
Topic: Media Technologies SubTopic: Video Tags:
Oct ’21
Reply to New iOS String Initializer can't get correct localized String for specific locale
You could try to specify the Bundle: extension String { func localized(for lanCode: String) -> String { guard let bundlePath = Bundle.main.path(forResource: lanCode, ofType: "lproj"), let bundle = Bundle(path: bundlePath) else { return "" } return NSLocalizedString( self, bundle: bundle, value: " ", comment: "" ) } } And call: "hello".localized(for: "cn") CRedit: https://stackoverflow.com/questions/28634428/ios-get-localized-version-of-a-string-for-a-specific-language
Topic: App & System Services SubTopic: General Tags:
Oct ’21
Reply to Can't render a Text view and DatePicker together in a sidebar list section in iOS 15
I get the same bug. Even adding a second section with EmptyView() or adding an EmptyView in First section do not change anything. I get the following error message in log when keeping datePicker alone and collapsing and restoring: 2021-10-04 08:21:45.040407+0200 SwiftUI 00 - zeroth for basic test[11653:339461] [Warning] Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a table view cell's content view. We're considering the collapse unintentional and using standard height instead. Cell: <SwiftUI.ListTableViewCell: 0x7fbf19824400; baseClass = UITableViewCell; frame = (0 40; 350 54.3333); clipsToBounds = YES; autoresize = W; layer = <CALayer: 0x6000013bcee0>> I set a frame size and it works OK: struct ContentView: View { @State private var selectedDate = Date() var body: some View { List { Section(header: Text("TextView and DatePicker")) { VStack { Text("TextView") DatePicker(selection: $selectedDate, displayedComponents: .date) { Text("DatePicker") } } .frame(height: 50) // <<-- ADDED } } .listStyle(.sidebar) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to Can't render a Text view and DatePicker together in a sidebar list section in iOS 15
I tried with minHeight:           .frame(minHeight: 50) But it doesn't work. This works, but will it fit your need ?           .frame(minHeight: 50, idealHeight: 50) It is probably the same constraint as frame(height). Could you compute the needed height ? Read this for help: h t t p s : / / newbedev.com/swiftui-hstack-with-wrap-and-dynamic-height In any case, that seems to be a bug in iOS that needs to be corrected. You should file a bug report.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to Instance member 'success' of type 'SignUp' cannot be used on instance of nested type 'SignUp.ContentView_Previews'
You should use a State var in Preview and a Binding in the View, as described here: https://stackoverflow.com/questions/60105438/swiftui-preview-provider-with-binding-variables Note: when you paste code, it is much better too use Paste And Match Style to avoid all the blank lines: import SwiftUI import FirebaseAuth import FirebaseDatabase struct SignUp: View { @State var Value: String = "" @State var username: String = "" @State var email: String = "" @State var password: String = "" @State var success = false var body: some View { NavigationView{ ZStack { LinearGradient(gradient: Gradient(colors: [Color.blue, Color.white]), startPoint: .topLeading, endPoint: .bottomTrailing) .ignoresSafeArea() Rectangle() .fill(Color.white) .frame(width: 300, height: 550) .cornerRadius(10) VStack(spacing: 30){ Image(systemName: "bitcoinsign.circle") .font(.system(size: 70, weight: .medium)) .padding() TextField("Username", text: $username) .frame(width: 200, height: 30) .padding() .overlay(RoundedRectangle(cornerRadius: 10.0).strokeBorder(Color.blue, style: StrokeStyle(lineWidth: 2.0))) .foregroundColor(.green) TextField("Email", text: $email) .frame(width: 200, height: 30) .padding() .overlay(RoundedRectangle(cornerRadius: 10.0).strokeBorder(Color.blue, style: StrokeStyle(lineWidth: 2.0))) .foregroundColor(.green) TextField("Password", text: $password) .frame(width: 200, height: 30) .padding() .overlay(RoundedRectangle(cornerRadius: 10.0).strokeBorder(Color.blue, style: StrokeStyle(lineWidth: 2.0))) .foregroundColor(.green) Button(action: { createUser(withEmail: email, password: password, username: username) success = true }, label: { Text("Sign Up") .frame(width: 200, height: 20, alignment: .center) .padding() .background(Color.blue) .foregroundColor(Color.white) .cornerRadius(15) }) } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { if success == false { SignUp() } else { Login() } } } } func createUser(withEmail email: String, password: String, username: String){ Auth.auth().createUser(withEmail: email, password: password) { (result, error) in if let error = error { print("Failed to sign user up", error.localizedDescription) return } else { guard let uid = result?.user.uid else { return} let values = ["email": email, "username":username] Database.database().reference().child(uid).child("users").updateChildValues(values, withCompletionBlock: { (error, ref) in if let error = error { print("failed to update databse values with error", error.localizedDescription) return } else { print("user successfully created..") } }) } } }
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’21
Reply to NSSavePanel crashes on runModal()
I use NSPanel differently, not as a basic Dialog: Line 26, I would change for: dialog.begin() { (result) -> Void in if result == NSApplication.ModalResponse.OK { let results = dialog.url // Do whatever you need with every selected file print ( results!.path ) } else { print ( "User clicked on 'Cancel'" ) return } } For reference: 1. import Cocoa 2. @main 3. class AppDelegate: NSObject, NSApplicationDelegate, NSComboBoxDelegate, NSOpenSavePanelDelegate { 4. 5. let dialog = NSSavePanel() 6. @IBOutlet var window: NSWindow! 7. @IBOutlet weak var selectOutFileLabelOutlet: NSTextField! 8. @IBOutlet weak var selectFileCBOutlet : NSComboBox! 9. @IBOutlet weak var ouputFileNameOutlet: NSTextField! 10. @IBOutlet weak var browse4FileOutlet : NSButton! 11. @IBOutlet weak var progressBarOutlet : NSProgressIndicator! 12. @IBOutlet weak var convertButtonOutlet: NSButton! 13. 14. @IBAction func convertButtonClicked(_ sender: Any) { 15. // STUB 16. } 17. 18. @IBAction func browseButtonClicked(_ sender: Any) { 19. dialog.title = "Choose output file" 20. dialog.showsResizeIndicator = true 21. dialog.showsHiddenFiles = true 22. dialog.canCreateDirectories = true 23. dialog.allowedFileTypes = [".ear", ".mer", ".ven", ".mar", ".jup", ".sat", ".ura", ".nep", ".plu"] 24. dialog.allowsOtherFileTypes = true 25. dialog.treatsFilePackagesAsDirectories = true 26. let answer = dialog.runModal() // ERROR 27. if answer == NSApplication.ModalResponse.OK { 28. let results = dialog.url 29. // Do whatever you need with every selected file 30. print ( results!.path ) 31. } else { 32. print ( "User clicked on 'Cancel'" ) 33. return 34. } 35. } 36. 37. var sourceFileName : String = "" 38. var targetFileName : String = "" 39. let resourcePathPrefix : String = "(Bundle.main.resourcePath!)/VSOP87-Files/" 40. var outputFilePath : String = "" 41. 42. func applicationDidFinishLaunching(_ aNotification: Notification) { 43. // Insert code here to initialize your application 44. dialog.delegate = self 45. selectFileCBOutlet.delegate = self 46. setupComboBox() 47. } 48. }
Topic: UI Frameworks SubTopic: AppKit Tags:
Oct ’21
Reply to Drawing images to PDF in a loop, the first image is being drawn each time in iOS 15 only
@JTForte If we want to still have the total page count as well then we will go with your suggestion of just recreating the final pdf after knowing the total page count. That's probably the best solution as for now. Note that you are not the only one to face the problem: https://developer.apple.com/forums/thread/691512 Which means problem is not with your code most likely. You should file a bug report.
Oct ’21
Reply to iPhone is busy: Making Apple Watch ready for development
Did you try to reboot the watch ? If that's not enough, try to unpair the watch from iPhone and pair it again.
Replies
Boosts
Views
Activity
Oct ’21
Reply to Data struct not working
Declare as optional: var orchard: Orchard? to solve first error. Note: photos are great, but code itself is easier to use. For the second, remove the parameter. You can also declare orchard inside ContentView: struct ContentView: View {     @State var orchard: Orchard?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Cannot convert value of type 'Binding<[Video]>.Type' to expected argument type 'Binding<[Video]>'
You should show more code. NavigationLink(destination: SomeView.init(data: Binding<[Video]> Is it in code ? You need to specify the argument. If you have defined: struct SomeView: View {     @Binding var data: Video Then, in the view with the NavigationLink, you should have: struct ContentView: View {     @State var contentData : Video = // need to give an initial value, as Video(some arg)     var body: some View {         NavigationView {                 NavigationLink(destination: SomeView(data: $contentData)) { or SomeView.init(data: $contentData)                     Text("Press on me with Binding")                 }.buttonStyle(PlainButtonStyle())             }         }
Topic: Media Technologies SubTopic: Video Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Xcode 11 iphone5 Failed to launch error
Hope you will find useful information here. https://stackoverflow.com/questions/31350957/fbsopenapplicationerrordomain-error-1 If not enough, maybe here: h t t p s : / / w w w.wikitechy.com/errors-and-fixes/ios/fbsopenapplicationerrordomain-code-4-error
Replies
Boosts
Views
Activity
Oct ’21
Reply to New iOS String Initializer can't get correct localized String for specific locale
You could try to specify the Bundle: extension String { func localized(for lanCode: String) -> String { guard let bundlePath = Bundle.main.path(forResource: lanCode, ofType: "lproj"), let bundle = Bundle(path: bundlePath) else { return "" } return NSLocalizedString( self, bundle: bundle, value: " ", comment: "" ) } } And call: "hello".localized(for: "cn") CRedit: https://stackoverflow.com/questions/28634428/ios-get-localized-version-of-a-string-for-a-specific-language
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Can't render a Text view and DatePicker together in a sidebar list section in iOS 15
I get the same bug. Even adding a second section with EmptyView() or adding an EmptyView in First section do not change anything. I get the following error message in log when keeping datePicker alone and collapsing and restoring: 2021-10-04 08:21:45.040407+0200 SwiftUI 00 - zeroth for basic test[11653:339461] [Warning] Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a table view cell's content view. We're considering the collapse unintentional and using standard height instead. Cell: <SwiftUI.ListTableViewCell: 0x7fbf19824400; baseClass = UITableViewCell; frame = (0 40; 350 54.3333); clipsToBounds = YES; autoresize = W; layer = <CALayer: 0x6000013bcee0>> I set a frame size and it works OK: struct ContentView: View { @State private var selectedDate = Date() var body: some View { List { Section(header: Text("TextView and DatePicker")) { VStack { Text("TextView") DatePicker(selection: $selectedDate, displayedComponents: .date) { Text("DatePicker") } } .frame(height: 50) // <<-- ADDED } } .listStyle(.sidebar) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Can't render a Text view and DatePicker together in a sidebar list section in iOS 15
I tried with minHeight:           .frame(minHeight: 50) But it doesn't work. This works, but will it fit your need ?           .frame(minHeight: 50, idealHeight: 50) It is probably the same constraint as frame(height). Could you compute the needed height ? Read this for help: h t t p s : / / newbedev.com/swiftui-hstack-with-wrap-and-dynamic-height In any case, that seems to be a bug in iOS that needs to be corrected. You should file a bug report.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Instance member 'success' of type 'SignUp' cannot be used on instance of nested type 'SignUp.ContentView_Previews'
You should use a State var in Preview and a Binding in the View, as described here: https://stackoverflow.com/questions/60105438/swiftui-preview-provider-with-binding-variables Note: when you paste code, it is much better too use Paste And Match Style to avoid all the blank lines: import SwiftUI import FirebaseAuth import FirebaseDatabase struct SignUp: View { @State var Value: String = "" @State var username: String = "" @State var email: String = "" @State var password: String = "" @State var success = false var body: some View { NavigationView{ ZStack { LinearGradient(gradient: Gradient(colors: [Color.blue, Color.white]), startPoint: .topLeading, endPoint: .bottomTrailing) .ignoresSafeArea() Rectangle() .fill(Color.white) .frame(width: 300, height: 550) .cornerRadius(10) VStack(spacing: 30){ Image(systemName: "bitcoinsign.circle") .font(.system(size: 70, weight: .medium)) .padding() TextField("Username", text: $username) .frame(width: 200, height: 30) .padding() .overlay(RoundedRectangle(cornerRadius: 10.0).strokeBorder(Color.blue, style: StrokeStyle(lineWidth: 2.0))) .foregroundColor(.green) TextField("Email", text: $email) .frame(width: 200, height: 30) .padding() .overlay(RoundedRectangle(cornerRadius: 10.0).strokeBorder(Color.blue, style: StrokeStyle(lineWidth: 2.0))) .foregroundColor(.green) TextField("Password", text: $password) .frame(width: 200, height: 30) .padding() .overlay(RoundedRectangle(cornerRadius: 10.0).strokeBorder(Color.blue, style: StrokeStyle(lineWidth: 2.0))) .foregroundColor(.green) Button(action: { createUser(withEmail: email, password: password, username: username) success = true }, label: { Text("Sign Up") .frame(width: 200, height: 20, alignment: .center) .padding() .background(Color.blue) .foregroundColor(Color.white) .cornerRadius(15) }) } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { if success == false { SignUp() } else { Login() } } } } func createUser(withEmail email: String, password: String, username: String){ Auth.auth().createUser(withEmail: email, password: password) { (result, error) in if let error = error { print("Failed to sign user up", error.localizedDescription) return } else { guard let uid = result?.user.uid else { return} let values = ["email": email, "username":username] Database.database().reference().child(uid).child("users").updateChildValues(values, withCompletionBlock: { (error, ref) in if let error = error { print("failed to update databse values with error", error.localizedDescription) return } else { print("user successfully created..") } }) } } }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Saving images in array in the same order in which it is selected using PHPickerViewController
Yes. Create the array, empty append the image to the array each time you pick an image.
Topic: Media Technologies SubTopic: General Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Is it possible to create a non-sandboxed app for iOS, that will actually install and run
Sandboxing is built deep inside the system. No way to turn around (legally).
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Error Analyzing App Version
When you get the error, did you "Show logs" ? What do you get ?
Replies
Boosts
Views
Activity
Oct ’21
Reply to NSSavePanel crashes on runModal()
I use NSPanel differently, not as a basic Dialog: Line 26, I would change for: dialog.begin() { (result) -> Void in if result == NSApplication.ModalResponse.OK { let results = dialog.url // Do whatever you need with every selected file print ( results!.path ) } else { print ( "User clicked on 'Cancel'" ) return } } For reference: 1. import Cocoa 2. @main 3. class AppDelegate: NSObject, NSApplicationDelegate, NSComboBoxDelegate, NSOpenSavePanelDelegate { 4. 5. let dialog = NSSavePanel() 6. @IBOutlet var window: NSWindow! 7. @IBOutlet weak var selectOutFileLabelOutlet: NSTextField! 8. @IBOutlet weak var selectFileCBOutlet : NSComboBox! 9. @IBOutlet weak var ouputFileNameOutlet: NSTextField! 10. @IBOutlet weak var browse4FileOutlet : NSButton! 11. @IBOutlet weak var progressBarOutlet : NSProgressIndicator! 12. @IBOutlet weak var convertButtonOutlet: NSButton! 13. 14. @IBAction func convertButtonClicked(_ sender: Any) { 15. // STUB 16. } 17. 18. @IBAction func browseButtonClicked(_ sender: Any) { 19. dialog.title = "Choose output file" 20. dialog.showsResizeIndicator = true 21. dialog.showsHiddenFiles = true 22. dialog.canCreateDirectories = true 23. dialog.allowedFileTypes = [".ear", ".mer", ".ven", ".mar", ".jup", ".sat", ".ura", ".nep", ".plu"] 24. dialog.allowsOtherFileTypes = true 25. dialog.treatsFilePackagesAsDirectories = true 26. let answer = dialog.runModal() // ERROR 27. if answer == NSApplication.ModalResponse.OK { 28. let results = dialog.url 29. // Do whatever you need with every selected file 30. print ( results!.path ) 31. } else { 32. print ( "User clicked on 'Cancel'" ) 33. return 34. } 35. } 36. 37. var sourceFileName : String = "" 38. var targetFileName : String = "" 39. let resourcePathPrefix : String = "(Bundle.main.resourcePath!)/VSOP87-Files/" 40. var outputFilePath : String = "" 41. 42. func applicationDidFinishLaunching(_ aNotification: Notification) { 43. // Insert code here to initialize your application 44. dialog.delegate = self 45. selectFileCBOutlet.delegate = self 46. setupComboBox() 47. } 48. }
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to XCode 15 Compiler Unable To Type Check
Is it the full message, or does it say "in reasonable time" ? Could you show code where you get such error ? Maybe you need to explicit the type of var ?
Replies
Boosts
Views
Activity
Oct ’21
Reply to Scroll View with text and img inside
When you say "5. you can keep the content layout and frame layout ON", what do you mean? That's in fact a UIKit setting as I said at start. You should probably just ignore this for Cocoa (could not find its exact equivalent).
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Drawing images to PDF in a loop, the first image is being drawn each time in iOS 15 only
@JTForte If we want to still have the total page count as well then we will go with your suggestion of just recreating the final pdf after knowing the total page count. That's probably the best solution as for now. Note that you are not the only one to face the problem: https://developer.apple.com/forums/thread/691512 Which means problem is not with your code most likely. You should file a bug report.
Replies
Boosts
Views
Activity
Oct ’21