Post

Replies

Boosts

Views

Activity

Reply to Directions to annotation from current location in MapKit
I would like to do this like here: https://www.raywenderlich.com/7738344-mapkit-tutorial-getting-started If you want to do things as shown in the tutorial, you need to instantiate a MKMapItem as instructed. As you are using MKPointAnnotation, you can define an extension like this: extension MKPointAnnotation { var mapItem: MKMapItem { let placemark = MKPlacemark(coordinate: self.coordinate) return MKMapItem(placemark: placemark) } } To utilized this extension, you may need to pass the right annotation (which needs to be an MKPointAnnotation) to didClickDetailDisclosureNavigation(button:). Which may be hard using a usual UIButton. You should better define your own button type which can hold an annotation. Not too complex: class AnnotationButton: UIButton { var annotation: MKPointAnnotation? } (Please do not put the extension and the class definition inside some other type. They need to be toplevel definitions.) Your code would become something like this: func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { guard !(annotation is MKUserLocation) else { return nil } //mapView.delegate = self //->Move this to `viewDidLoad()` //This `annotationView` will be shadowed by the following `annotationView`, not used. //let annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: String(annotation.hash)) let identifier = "identifier" //annotationView.canShowCallout = true guard let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier, for: annotation) as? MKMarkerAnnotationView else { return nil } //... let leftButton = AnnotationButton(frame: CGRect( //<- origin: .zero, size: CGSize(width: 25, height: 25))) leftButton.setBackgroundImage(#imageLiteral(resourceName: "nav"), for: .normal) annotationView.leftCalloutAccessoryView = leftButton leftButton.addTarget(self, action: #selector(didClickDetailDisclosureNavigation(button:)), for: .touchUpInside) //↓↓ if let pointAnnotation = annotation as? MKPointAnnotation { leftButton.annotation = pointAnnotation } //... return annotationView } @objc func didClickDetailDisclosureNavigation(button: AnnotationButton) { //<- let launchOptions = [MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving] //↓↓ if let mapItem = button.annotation?.mapItem { mapItem.openInMaps(launchOptions: launchOptions) } } I haven't tried it myself (as you are not showing many parts of your code), but please try.
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’21
Reply to UILabel with superscript text
Several ways. Some examples: //Using attributed string let baseString = NSAttributedString(string: "1:47", attributes: [ .font: UIFont.systemFont(ofSize: 48), ]) let pmString = NSAttributedString(string: "PM", attributes: [ .baselineOffset: 16, .font: UIFont.systemFont(ofSize: 28), ]) let attributedString = NSMutableAttributedString() attributedString.append(baseString) attributedString.append(pmString) label1.attributedText = attributedString label1.backgroundColor = .black label1.textColor = .white //Using Unicode characters //let text = "1:47\u{1D3E}\u{1D39}" let text = "1:47\u{1D2C}\u{1D39}" label2.text = text label2.backgroundColor = .black label2.textColor = .white If you can find a better font (which may not be included in standard iOS devices), the result may get better:
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’21
Reply to SwiftUI Table does not work when trying to use Int values
I tried your code with Xcode 3.1 and got the following error: (I needed to fill many parts missing in your shown code, so some other parts still hidden may be affecting.) The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions The error is far from kind enough for fixing the issue, but it may very often caused by some obvious syntax errors in a ViewBuilder. As far as I check the code, this line is obviously odd: TableColumn("disc", Int: \.discNumber) TableColumn does not have an initializer init(_:Int:). And any initializers of TableColumn taking a KeyPath to Int requires RowValue as NSObject. So, a simple workaround may be defining an extension which return String. extension AlbumTracks { var discNumberString: String { String(discNumber) } } And use it as follows: TableColumn("disc", value: \.discNumberString) But as already noted, other parts may be affecting. If this workaround does not work, you may need to show more info.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to Axie infinity
Contact to the author of the app directly. The developer site is not a place to request joining to TestFlight.
Oct ’21
Reply to Navigation title not appearing correctly in SwiftUI
That depends on the global view hierarchy of your app. Often found in apps having nested NavigationView. Can you show the complete code to reproduce the issue? From the root view of your app to the view showing the screen shot.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Xcode 13: Active breakpoint turns to an outline when app is run.
I'm working on several projects which were created with Xcode 12.x (or older), but have never experienced the behavior as you described. Can you share the screen shots?
Replies
Boosts
Views
Activity
Oct ’21
Reply to Directions to annotation from current location in MapKit
I would like to do this like here: https://www.raywenderlich.com/7738344-mapkit-tutorial-getting-started If you want to do things as shown in the tutorial, you need to instantiate a MKMapItem as instructed. As you are using MKPointAnnotation, you can define an extension like this: extension MKPointAnnotation { var mapItem: MKMapItem { let placemark = MKPlacemark(coordinate: self.coordinate) return MKMapItem(placemark: placemark) } } To utilized this extension, you may need to pass the right annotation (which needs to be an MKPointAnnotation) to didClickDetailDisclosureNavigation(button:). Which may be hard using a usual UIButton. You should better define your own button type which can hold an annotation. Not too complex: class AnnotationButton: UIButton { var annotation: MKPointAnnotation? } (Please do not put the extension and the class definition inside some other type. They need to be toplevel definitions.) Your code would become something like this: func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { guard !(annotation is MKUserLocation) else { return nil } //mapView.delegate = self //->Move this to `viewDidLoad()` //This `annotationView` will be shadowed by the following `annotationView`, not used. //let annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: String(annotation.hash)) let identifier = "identifier" //annotationView.canShowCallout = true guard let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier, for: annotation) as? MKMarkerAnnotationView else { return nil } //... let leftButton = AnnotationButton(frame: CGRect( //<- origin: .zero, size: CGSize(width: 25, height: 25))) leftButton.setBackgroundImage(#imageLiteral(resourceName: "nav"), for: .normal) annotationView.leftCalloutAccessoryView = leftButton leftButton.addTarget(self, action: #selector(didClickDetailDisclosureNavigation(button:)), for: .touchUpInside) //↓↓ if let pointAnnotation = annotation as? MKPointAnnotation { leftButton.annotation = pointAnnotation } //... return annotationView } @objc func didClickDetailDisclosureNavigation(button: AnnotationButton) { //<- let launchOptions = [MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving] //↓↓ if let mapItem = button.annotation?.mapItem { mapItem.openInMaps(launchOptions: launchOptions) } } I haven't tried it myself (as you are not showing many parts of your code), but please try.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to NSInternalInconsistencyException
Can you make the stack trace formatted?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Unable to transition to the next screen modal with viewStore.binding in SwiftUI
Can you show what is viewStore?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to UILabel with superscript text
Several ways. Some examples: //Using attributed string let baseString = NSAttributedString(string: "1:47", attributes: [ .font: UIFont.systemFont(ofSize: 48), ]) let pmString = NSAttributedString(string: "PM", attributes: [ .baselineOffset: 16, .font: UIFont.systemFont(ofSize: 28), ]) let attributedString = NSMutableAttributedString() attributedString.append(baseString) attributedString.append(pmString) label1.attributedText = attributedString label1.backgroundColor = .black label1.textColor = .white //Using Unicode characters //let text = "1:47\u{1D3E}\u{1D39}" let text = "1:47\u{1D2C}\u{1D39}" label2.text = text label2.backgroundColor = .black label2.textColor = .white If you can find a better font (which may not be included in standard iOS devices), the result may get better:
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Axie Infinity Redeem Code
Contact to the author of the app.
Replies
Boosts
Views
Activity
Oct ’21
Reply to Icloud
Your question has nothing to do with the WWDC 21 session 10002. Choosing the right tag will help getting the right solution sooner.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to SwiftUI Table does not work when trying to use Int values
I tried your code with Xcode 3.1 and got the following error: (I needed to fill many parts missing in your shown code, so some other parts still hidden may be affecting.) The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions The error is far from kind enough for fixing the issue, but it may very often caused by some obvious syntax errors in a ViewBuilder. As far as I check the code, this line is obviously odd: TableColumn("disc", Int: \.discNumber) TableColumn does not have an initializer init(_:Int:). And any initializers of TableColumn taking a KeyPath to Int requires RowValue as NSObject. So, a simple workaround may be defining an extension which return String. extension AlbumTracks { var discNumberString: String { String(discNumber) } } And use it as follows: TableColumn("disc", value: \.discNumberString) But as already noted, other parts may be affecting. If this workaround does not work, you may need to show more info.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to SwiftUI Table does not work when trying to use Int values
Can you show enough code to compile your code? Especially, what is AlbumDetails? In addition, AppleMusicAPI and WebImage are also needed.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to ObjectCapture API has an arbitrary limit of 1000 PhotogrammetrySamples
Sharing your demands is not a bad thing, but this is not a good place to request something to Apple. Have you sent a feedback to Apple?
Topic: Graphics & Games SubTopic: RealityKit Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Detecting an Archive vs. Development build
Not sure if this is the best solution to achieve what you want, but I would add another Configuration for Archive. You can choose the Build Configuration in the Scheme editor of Archive, and you can put a Custom Flag in the Build Settings for Archive configuration.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to List in SwiftUI not appearing correctly.
Can you show your code?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to cannot find type in scope xcode 13
@YShaw, the same error declaration would help very little solving your issue. You should better start your own thread with including enough info.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Axie infinity
Contact to the author of the app directly. The developer site is not a place to request joining to TestFlight.
Replies
Boosts
Views
Activity
Oct ’21