Post

Replies

Boosts

Views

Activity

UIDocumentPickerViewController directoryURL no longer opening correct folder
Since iOS 18, I have gotten user reports that the UIDocumentPickerViewController directoryURL is no longer opening the correct folder. Instead it is just loading the root directory of the Files app/iCloud files. Did something change in iOS 18 that I need to account for? Not all users are having this issue, but some are and they are frustrated because a major feature of my app was to allow users to save files at the ubiquityURL. I use the following to get the path: NSURL *rootDirectory = [[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil] URLByAppendingPathComponent:[NSString stringWithFormat:@"Documents/Photos/%@", folderName]]; Is there something that I need to do differently now in iOS 18 to prevent this from happening?
0
0
148
3w
CPVoiceControlState repeating image?
I am trying to use CPVoiceControlState and include an animated image, but for the life of me I cannot figure out what sort of image it wants. I have tried animated .gif, .png, a static image, an image sequence and none seem to animate. Here is what I am using with an animated .png: func showLoadingTemplate() { enum VoiceControlStates: String { case loading = "loading" } let spinner = UIImage(named: "spinner") loadingTemplate = CPVoiceControlTemplate(voiceControlStates: [ CPVoiceControlState(identifier: VoiceControlStates.loading.rawValue, titleVariants: [NSLocalizedString("Loading...", comment: "CarPlay: Loading")], image: spinner, repeats: true) ]) loadingTemplate?.activateVoiceControlState(withIdentifier: VoiceControlStates.loading.rawValue) if let loading = loadingTemplate { currentInterfaceController?.presentTemplate(loading, animated: true, completion: { (result: Bool, error: Error?) in }) } } This shows the image but it isn't animating. Can anyone let me know what sort of image needs to be used in order to get it to animate? I have seen animated images working in Waze and Google Maps so if must be possible.
1
0
284
Sep ’24
Using CPVoiceControlTemplate in my CarPlay app to capture voice
I have a CarPlay navigation app and I would like to allow the user to speak an address and have our app search at that location. In the Waze app, it provides a button to tap, then it brings up a CPVoiceControlTemplate and you can give it directions or a location and it will then show you search results including the text you spoke as the title. I assume that app would have the same limitations as I do, so I am wondering how another app might do this? It was suggested that I use an App Intent with suggested phrases and then a Shortcut could perform the action. Is there documentation on this somewhere or am I going in the wrong direction here? Obviously Waze is doing what I am wanting so there must be a way. Can anyone point me in the right direction?
2
1
486
Sep ’24
Swift Package with @objc cannot find interface declaration
I am using a Swift PM module and adding it to a brand new project. This project is Objective-C based, but I would like to use the module within a .swift file as I am working to migrate part of my project to Swift. The .swift file is called from the Objective-C app delegate. When doing this method on a brand new project, it builds correctly. However, when I add the module to my production app (has been in development for 10 years) in the same way, I get the following error in my MyApp-Swift.h file: Cannot find interface declaration for 'MBNavigationViewController', superclass of 'CarPlayMapViewController'; did you mean 'UINavigationController'? I have even created a stripped down version of my app with minimal files and it still does not build. There must be some build setting or something else that allows the module to work in a brand new project (accessing the MyApp-Swift.h file that generates the Obj-C methods) but not in my older project?
1
0
589
Jul ’24
State Restoration: Deleting current state data
In the past, it seemed that if you used the app switcher and killed the app, that state restoration data would not persist, and starting the app again would not load any stored state data. But now (at lest in iOS 17) that is no longer the case. There are situations where the old state might cause issues, which we obviously need to fix, but users should be able to clear the state data. I am not using sessions and am using the older methods - application:shouldSaveApplicationState: and application:shouldRestoreApplicationState:. My question is, how can I tell my users to reset/clear state restoration data if needed?
0
0
328
Jun ’24
Driving Task Crash When Adding Action Sheet or Alert
I have a driving task app and am trying to show a CPActionSheetTemplate or a CPAlertTemplate. Both of these are crashing showing: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unsupported object <CPActionSheetTemplate: 0x6000030319e0> <identifier: C744031B-99F6-4999-AF19-6ED43140502B, userInfo: (null), tabTitle: (null), tabImage: (null), showsTabBadge: 0> passed to pushTemplate:animated:completion:. Allowed classes: {( CPSearchTemplate, CPNowPlayingTemplate, CPPointOfInterestTemplate, CPListTemplate, CPInformationTemplate, CPContactTemplate, CPGridTemplate, CPMapTemplate )}' This is very strange, because in the docs all app types are allowed to show ActionSheets and Alerts. Why is this crashing?
1
0
718
Dec ’23
iOS 15 change in MKTileOverlay and tileSize?
In our iOS app we use a MKTileOverlay subclass and set tileSize to CGSizeMake(512, 512). This allows tiled maps such as Open Street Maps to display larger for those that need larger font sizes. Since iOS 15 this no longer works, and the tiles are not large anymore and are small, similar to how it was before we added this feature. Once tileSize has been set, we use loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData *, NSError *))result to return the larger image NSData in the result. Did something change in OS 15 and MKTileOverlay and tileSize that would require some changes on our end?
0
0
718
Sep ’21
Center on screen two annotations while allowing MKCamera heading updates creates very jerky animations
In my app, I have a mode that rotates the MKMapView camera heading based on Core Location heading updates. This works great. [UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ self.mapView.camera.heading = theHeading;//Comes from CLHeading } completion:nil]; At the same time, I have two annotations, one is the current location, that I always want to keep on screen. So as the user gets closer to one of the annotations, the map will continue to zoom in. MKMapRect flyTo = MKMapRectNull; if (location) { MKMapPoint annotationPoint = MKMapPointForCoordinate(location.coordinate); MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0); if (MKMapRectIsNull(flyTo)) { flyTo = pointRect; } else { flyTo = MKMapRectUnion(flyTo, pointRect); } } if (CLLocationCoordinate2DIsValid(self.selectedCoordinate)) { MKMapPoint annotationPoint = MKMapPointForCoordinate(self.selectedCoordinate); MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0); if (MKMapRectIsNull(flyTo)) { flyTo = pointRect; } else { flyTo = MKMapRectUnion(flyTo, pointRect); } } [self.mapView setVisibleMapRect:flyTo edgePadding:UIEdgeInsetsMake(30, 30, 30, 30) animated:animated]; The Problem The big issue here, is that as the user rotates the device, and the heading is updated, the visibleMapRect is also updated to keep both annotations on the map. This causes the map to animate back to "north up" and then quickly back to rotating the map camera. This creates a very jerky movement which is not what I want. Is it possible to set the visibleMapRect and the camera heading at the same time without this negative side effect?
0
0
882
Apr ’21
MKPolyline replacement causes MKTileOverlay to flash on map since iOS 13
I have an MKMapView that has a MKTileOverlay so that I can show Open Street Map tiles:NSString *templateURL = @"http://tile.openstreetmap.org/{z}/{x}/{y}.png"; self.tileOverlay = [[MKTileOverlay alloc] initWithURLTemplate:templateURL]; self.tileOverlay.canReplaceMapContent = YES; [self.mapView addOverlay:self.tileOverlay level:MKOverlayLevelAboveLabels];I also want to show an MKPolyline from my current location to Apple Park in Cupertino. This polyline needs to be updated as I move, and since an MKPolyline object isn't mutable, I have to remove it and add it for each location update:- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray*)locations { self.currentLocation = userLocation; // Update polyline CLLocationCoordinate2D applePark = CLLocationCoordinate2DMake(37.334626, -122.008895); [self buildPolylineWithDestinationLocation:applePark]; } - (void)buildPolylineWithDestinationLocation:(CLLocationCoordinate2D)coordinate { // Remove the polyline each time so we can redraw it if (self.polylineApple) { [self.mapView removeOverlay:self.polylineApple]; } // Get current location CLLocation *location = self.currentLocation; CLLocationCoordinate2D currentLocation = location.coordinate; CLLocationCoordinate2D points[2]; points[0] = currentLocation; points[1] = coordinate; // Remove all route polylines MKPolyline *oldPolyline = self.polylineApple; // Draw a line self.polylineApple = [MKPolyline polylineWithCoordinates:points count:2]; [self.mapView addOverlay:self.polylineApple]; if (oldPolyline) { [self.mapView removeOverlay:oldPolyline]; oldPolyline = nil; } }The problem is, this used to work great in older versions of iOS, but ever since iOS 13 this has caused the tiles to be redrawn each time that MKPolyline is removed and added. See:https://i.stack.imgur.com/9nJEO.gifIs this just an iOS 13 bug, or is there something I need to fix in my code to make this not happen?
1
0
1.5k
Dec ’19