Post

Replies

Boosts

Views

Activity

Reply to KMLViewer (Map Kit): MKPointAnnotation text not displayed
I would never have gotten that idea - that the documentation on MapKit - MKMapView - is so misleading...  Archived documentations will never be updated, even if they contained inappropriate description. But the latest documents will give you some hints: MKMarkerAnnotationView - https://developer.apple.com/documentation/mapkit/mkmarkerannotationview ... Setting the Visibility var titleVisibility: MKFeatureVisibility The visibility of the title text rendered beneath the marker balloon. ... You can try something like this: let marker = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: nil) marker.displayPriority = .required marker.titleVisibility = .visible //- _annotationView = marker
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Use of AutoreleasingUnsafeMutablePointer in Swift
This is the Obj-C implementation in the demo.app provided by Zebra Based on the sample code in Objective-C, you need to set an instance of NSMutableArray before you call sbtGetAvailableScannersList(_:). Please try something like this: var availableScanners: NSMutableArray? = NSMutableArray() scanner?.sbtGetAvailableScannersList(&availableScanners)
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Reset Values After A Calculation + Picker Selection
when I change the picker options, it internalizes the user input and doesn't allow the user to change inputs anymore. Sorry, but I do not understand this part. Do you want to update the value shown in timeOutput automatically? Or do you just want to set default values to fields and pickers? If the latter, you just need to call a function which resets values to default: @IBAction func btnCalcClicked(){ //The code below this is to perform the necessary air calculations. //... //Outputs the time allowed for the dive, in minutes, based on all factors input. resetValues() } func resetValues() { allowedTime = 0 consumptionAir = 0 volumeAvailable = 0 //... picker.selectRow(0, inComponent: 0, animated: false) pickerCyl.selectRow(0, inComponent: 0, animated: false) } If this is not what you mean, please try to explain what you want to do again.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Failed to produce diagnostic for expression when creating a list view in SwiftUI
In your code, Playlist is Identifiable, but the Element type of playlist.songs is not. Try adding this extension to Song: extension Song: Identifiable { var id: String {Name} //- Please change this, if you know something better for `id` } (Or else, you can add id: parameter to ForEach.) Swift compiler cannot find the right initializer of ForEach when the Element is not Identifiable, but at least it should show some sort of errors on line 12. You can send a bug report to Apple using the Apple's Feedback Assistant, or you can choose bugs.swift.org as suggested.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to push or local notification
the notifications appear when the app get new post from url It depends on what precisely means the app get new post from url. If you mean your app retrieves some post from the url with your code while your app is running, you can use local notifications.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to KMLViewer (Map Kit): MKPointAnnotation text not displayed
According to that, it is the KMLviewer code that removes annotations based on zoom level. But where is that code? NO. There's no such code in the KMLViewer. Maybe Apple's engineer included such functionality, described in the old archived document, into MKMapView itself. Searching with mkmapview overlapping annotations I could find a good suggestion: medium.com/swlh/how-to-stop-mapkit-annotation-clustering-790bcb7b8329 let marker = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: nil) marker.displayPriority = .required //- _annotationView = marker
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to MKPolyline 'inside' an MKOverlay: How do I access the points that construct the line?
So the overall question still remains: Why are none of the MKPolyline(s) visible on the map? For more information on this project, see https://developer.apple.com/forums/thread/680107 So, thanks for checking. As suggested by Claud31, it seems KMLParser cannot detect the right styles for LineString in kml. As you know, the original KML_Sample.kml does not contain LineString elements, I guess the feature was not fully tested. I wrote some partial answer on the original thread you have shown. But, to show your kml file more precisely as it is, you may need to update KMLParser and all related types.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to KMLViewer (Map Kit): MKPointAnnotation text not displayed
Can any one help me figure out why? As far as I tried KMLViewer with your kml shown in another thread of yours, the title was shown in the callout when I tapped the pin. I think this is the usual behavior of MKPinAnnotationView. If you want to show the title sort of permanently, you may need to use another annotation view class. For example: var annotationView: MKAnnotationView? { if _annotationView == nil { if let annotation = self.point { if #available(iOS 11.0, *) { let marker = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: nil) _annotationView = marker } else { // Fallback on earlier versions let pin = MKPinAnnotationView(annotation: annotation, reuseIdentifier: nil) pin.canShowCallout = true pin.animatesDrop = true _annotationView = pin } } } return _annotationView } Or else, if you do not prefer any of the predefined annotation view classs, you can create your own custom class by subclassing MKAnnotationView.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Wait until transaction is finished
Many things omitted in YouTube tutorials. Better learn official documentations alongside with video tutorials. In-App Purchase - https://developer.apple.com/documentation/storekit/in-app_purchase Please read all the articles and when finished reading, please tell us which part of which document you do not understand.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Picker View Data used elsewhere
In your ScubaViewController, the property data is initialized with an Array of 7 elements and it cannot be modified. Thus, any of the conditions of your if-statements never get true. You need to get the selected value from picker. An example: @IBAction func btnCalcClicked() { let selectedRow = picker.selectedRow(inComponent: 0) guard data.indices.contains(selectedRow) else { print("selectedRow invalid") return } let selectedData = data[selectedRow] if selectedData == "Aluminum 100" { fv = 0.47 } else if selectedData == "Aluminum 80" { fv = 0.399 } else if selectedData == "Aluminum 63" { fv = 0.319 } else if selectedData == "Aluminum 50" { fv = 0.281 } else if selectedData == "Steel 120" { fv = 0.526 } else if selectedData == "Steel 100" { fv = 0.445 } else if selectedData == "Steel 72" { fv = 0.42 } consumptionAir = Double(((Double(plannedDepth.text!)! + 33)/33)) * 1.4 volumeAvailable = Double((Double(cylinderPSI.text!)! - mmP) / 14.7) * fv * cylN allowedTime = volumeAvailable / consumptionAir timeOutput.text = String(allowedTime) //Outputs the time allowed for the dive, in minutes, based on all factors input. } (I have renamed FV to fv, as in Swift, only type names start with Capital letter.) But writing bunch of if-statements is not preferred. I would write something like this: class ScubaViewController: UIViewController { //... var fv: Double = 0.0 //... let data = [ //Give this a better name than `data`... (title: "Aluminum 100", fv: 0.47), (title: "Aluminum 80", fv: 0.399), (title: "Aluminum 63", fv: 0.319), (title: "Aluminum 50", fv: 0.281), (title: "Steel 120", fv: 0.526), (title: "Steel 100", fv: 0.445), (title: "Steel 72", fv: 0.42) ] //... @IBOutlet var picker: UIPickerView! //... @IBAction func btnCalcClicked() { let selectedRow = picker.selectedRow(inComponent: 0) guard data.indices.contains(selectedRow) else { print("selectedRow invalid") return } fv = data[selectedRow].fv //... } //... } //... extension ScubaViewController: UIPickerViewDelegate{ func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent: Int) - String? { return data[row].title } }
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to How can I call Swift extension method in my Objective-C class?It doesn't work when using @objc.
NSData is automatically bridged to Data in Swift, but it does not mean extension for Data is available in NSData. You may need another extension for NSData, something like: extension NSData { @objc func AES128Encrypt() throws - Data { return try (self as Data).AES128Encrypt() } } And you need to know how Swift methods with throws are converted to Objective-C: #import "YourModuleName-Swift.h" //... NSError *error = nil; NSData *encryptedData = [resultData AES128EncryptAndReturnError:&error]; //...
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to How to Show Alert from Anywhere in app SwiftUI?
According to the error message, both sheet and alert are implemented as a type of alert controller. As you know, you cannot show an alert while another alert is already shown. You may need to close the sheet before showing an alert: struct ContentView: View { @State var showAlert: Bool = false @State var showSheet: Bool = false var body: some View { NavigationView { Button(action: { showSheet = true }, label: { Text("Show Sheet") }).padding() .sheet(isPresented: $showSheet, content: { SheetView(showAlert: $showAlert, showSheet: $showSheet) }) } .alert(isPresented: $showAlert, content: { Alert(title: Text("Alert")) }) } } struct SheetView: View { @Binding var showAlert: Bool @Binding var showSheet: Bool @State var showAlertOnDisappear: Bool = false var body: some View { Button(action: { showSheet = false showAlertOnDisappear = true }, label: { Text("Show Alert") }) .onDisappear { if showAlertOnDisappear { showAlert = true } } } } Or else, you may need to implement Anywhere-alert in some other ways.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to How to declare a scope in code ?
How do I #define  AdvancedSettingsView in my code ? It depends on what sort of View you want to show. Codes shown in reference are intended show outlines of the usage, they are often not complete as c&p ready. If you cannot fill in the missing parts, you should better not copy codes in some reference, but better find a good tutorial.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to How to declare a scope in code ?
My issue is the following : "I want to program a function and I receive a 'scope' error". How do I declare a scope and were in my programming code to allow the variable to function in accordance with the iOS Mobile App that I want to develop these year ? As already said, scope is not something you define. Ignore the word scope in the error message and find what you need to define. What you need to do is described in the other parts than scope in the error message. If you get Cannot find AdvancedSettingsView in scope, it is AdvancedSettingsView that you need to define, not scope.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21