Post

Replies

Boosts

Views

Activity

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 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 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 Xcode Simulator Rotate
Why isn't the app screen properly rotated when the app first launches in the simulator? I'm not sure if Apple's engineer would respond to this question. But none of the software features cannot move the actual physical device orientation in the hand of user. So, the simulator is properly simulating the behavior of your app, when user holds an iPad in the portrait orientation. In a few generations ago, old Xcode are changing orientation according to the orientation settings of the app. In fact, I was a little confused when this change was first introduced. But, now, I am accustomed to it and thinking that this behavior is quite reasonable.
Oct ’21
Reply to What to use for animating app for iOS
Which UI framework are you using? UIKit or SwiftUI? I have no knowledge of Adobe Animate, but you may need to learn and find what would be the iOS way of animating. Learning Core Animation APIs will help you constructing animations, but in most simple cases, using animations in iOS apps is far more simple. You can find many tutorials or guides searching with "ios animation". Or to get more specific results, "ios uikit animation" or "ios swiftui animation". Better try one of them and post more specific issues you experience.
Oct ’21
Reply to xCode 13.1 -- MKMap mapView.addOverlay -- Compiler Error: Invalid library file
If you could show a complete code (including MapViewModel and the view showing MKMap), more readers would be involved solving your issue. The message Compiler Error: Invalid library file seems to be so called a log noise and you may need to ignore them. You can find many articles discussing the issue searching with "Compiler Error: Invalid library file". You can file a bug report, but do not expect too much, this issue has being left for years. Your implementation of UIViewRepresentable has some inappropriate parts, but the core reason you cannot find the overlay on map might be because you have not set colors of MKCircleRenderer. struct MKMap: UIViewRepresentable { @ObservedObject var vm: MapViewModel = MapViewModel.shared //↓Do not instantiate a UIView in a property initializer //let mapView = MKMapView() func makeCoordinator() -> Coordinator { Coordinator(self) } // This funciton is called when we make the view func makeUIView(context: Context) -> MKMapView { let mapView = MKMapView() //<- mapView.delegate = context.coordinator mapView.userLocation.title = "user" mapView.showsUserLocation = true let point = CLLocationCoordinate2D(latitude: -73.68118286132812, longitude: 45.48589125320114) let overlay = MKCircle(center: point, radius: 30) mapView.addOverlay(overlay) let region = MKCoordinateRegion(center: vm.center, span: vm.span) mapView.setRegion(region, animated: true) return mapView } // Function called when the view is updated func updateUIView(_ mapView: MKMapView, context: Context) { //↓↓You need to prepare for updates... let region = MKCoordinateRegion(center: vm.center, span: vm.span) mapView.setRegion(region, animated: true) //... } } class Coordinator: NSObject, MKMapViewDelegate, CLLocationManagerDelegate{ var parent: MKMap init(_ parent: MKMap){ self.parent = parent } func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { if let circle = overlay as? MKCircle { //<- print("--->>> I'm inside the rendererFor overlay in MKCircle Statement <<<---") let renderer = MKCircleRenderer(circle: circle) //<- renderer.fillColor = .green //<-# renderer.lineWidth = 100 //<- Isn't it too wide? renderer.strokeColor = .red //<-# return renderer } return MKOverlayRenderer() } }
Topic: UI Frameworks SubTopic: SwiftUI 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:
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 Axie Infinity Redeem Code
Contact to the author of the app.
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 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 NSInternalInconsistencyException
Can you make the stack trace formatted?
Topic: UI Frameworks SubTopic: UIKit Tags:
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 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 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 Simulator Rotate
Why isn't the app screen properly rotated when the app first launches in the simulator? I'm not sure if Apple's engineer would respond to this question. But none of the software features cannot move the actual physical device orientation in the hand of user. So, the simulator is properly simulating the behavior of your app, when user holds an iPad in the portrait orientation. In a few generations ago, old Xcode are changing orientation according to the orientation settings of the app. In fact, I was a little confused when this change was first introduced. But, now, I am accustomed to it and thinking that this behavior is quite reasonable.
Replies
Boosts
Views
Activity
Oct ’21
Reply to Manage hit test mask in SwiftUI for an Image with transparency
What you are trying is not so simple and basic even in UIKit. Can you share the complete code of your current (complicated) solution? Some readers might think of improvements if they could see the code.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to What to use for animating app for iOS
Which UI framework are you using? UIKit or SwiftUI? I have no knowledge of Adobe Animate, but you may need to learn and find what would be the iOS way of animating. Learning Core Animation APIs will help you constructing animations, but in most simple cases, using animations in iOS apps is far more simple. You can find many tutorials or guides searching with "ios animation". Or to get more specific results, "ios uikit animation" or "ios swiftui animation". Better try one of them and post more specific issues you experience.
Replies
Boosts
Views
Activity
Oct ’21
Reply to xCode 13.1 -- MKMap mapView.addOverlay -- Compiler Error: Invalid library file
If you could show a complete code (including MapViewModel and the view showing MKMap), more readers would be involved solving your issue. The message Compiler Error: Invalid library file seems to be so called a log noise and you may need to ignore them. You can find many articles discussing the issue searching with "Compiler Error: Invalid library file". You can file a bug report, but do not expect too much, this issue has being left for years. Your implementation of UIViewRepresentable has some inappropriate parts, but the core reason you cannot find the overlay on map might be because you have not set colors of MKCircleRenderer. struct MKMap: UIViewRepresentable { @ObservedObject var vm: MapViewModel = MapViewModel.shared //↓Do not instantiate a UIView in a property initializer //let mapView = MKMapView() func makeCoordinator() -> Coordinator { Coordinator(self) } // This funciton is called when we make the view func makeUIView(context: Context) -> MKMapView { let mapView = MKMapView() //<- mapView.delegate = context.coordinator mapView.userLocation.title = "user" mapView.showsUserLocation = true let point = CLLocationCoordinate2D(latitude: -73.68118286132812, longitude: 45.48589125320114) let overlay = MKCircle(center: point, radius: 30) mapView.addOverlay(overlay) let region = MKCoordinateRegion(center: vm.center, span: vm.span) mapView.setRegion(region, animated: true) return mapView } // Function called when the view is updated func updateUIView(_ mapView: MKMapView, context: Context) { //↓↓You need to prepare for updates... let region = MKCoordinateRegion(center: vm.center, span: vm.span) mapView.setRegion(region, animated: true) //... } } class Coordinator: NSObject, MKMapViewDelegate, CLLocationManagerDelegate{ var parent: MKMap init(_ parent: MKMap){ self.parent = parent } func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { if let circle = overlay as? MKCircle { //<- print("--->>> I'm inside the rendererFor overlay in MKCircle Statement <<<---") let renderer = MKCircleRenderer(circle: circle) //<- renderer.fillColor = .green //<-# renderer.lineWidth = 100 //<- Isn't it too wide? renderer.strokeColor = .red //<-# return renderer } return MKOverlayRenderer() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Testflight for axie infinity
Contact to the author of the app. The developer site is not a place to request to be a TestFlight tester of some specific app.
Replies
Boosts
Views
Activity
Oct ’21