I am working on an iPad app using the front camera. The camera logic is implemented using the AVFoundation framework. During a session I use central stage mode to center the face with front camera . Central stage mode works fine in all cases except when I set the session preset photo. In other presets: high, medium, low, cif352x288, vga640x480, hd1280x720, hd1920x1080, iFrame960x540, iFrame1280x720, inputPriority presets central stage mode working except photo session preset. Can you explain why this happens or maybe it is an unobvious bug?
Code snippet:
final class CameraManager {
//MARK: - Properties
private let captureSession: AVCaptureSession
private let photoOutput: AVCapturePhotoOutput
private let previewLayer: AVCaptureVideoPreviewLayer
//MARK: - Init
init() {
captureSession = AVCaptureSession()
photoOutput = AVCapturePhotoOutput()
previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
}
//MARK: - Methods Setup Camera and preview layer
func setupPreviewLayerFrame(view: UIView) {
previewLayer.frame = view.frame
view.layer.insertSublayer(previewLayer, at: 0)
setupCamera()
}
private func setupCamera() {
guard let videoCaptureDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .front) else { return }
AVCaptureDevice.centerStageControlMode = .app
AVCaptureDevice.isCenterStageEnabled = true
do {
let input = try AVCaptureDeviceInput(device: videoCaptureDevice)
captureSession.addInput(input)
captureSession.addOutput(photoOutput)
/// high, medium, low, cif352x288, vga640x480, hd1280x720, hd1920x1080, iFrame960x540, iFrame1280x720 and inputPriority presets working except photo session preset
captureSession.sessionPreset = .photo
DispatchQueue.global(qos: .userInteractive).async {
self.captureSession.startRunning()
}
} catch {
print("Error setting up camera: \(error.localizedDescription)")
}
}
}
Posts under iPadOS tag
192 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
To enable editing in the elevated Tab Bar or sidebar on iPadOS, we need to use UITabBar. However, using UITabBar restricts reordering in compact mode with the bottom tab bar. Instead of showing the tabs, the editing view only displays the message 'Drag the icons to organize tabs.' How can we resolve this issue?
Find demo project here
iOS 18 introduced the elevated tab bar for iPad devices. However, the tint color for UITabBar items is not changing. Adjusting the barTintColor and tintColor properties of the tab bar items does not seem to have any effect.
I have been using UIDocumentInteractionController and presentOptionsMenuFromRect for sharing PDFs for years.
Now I get these errors.
Only support loading options for CKShare and SWY types.
[ERROR] failed to get service endpoint creating for for item at URL
Collaboration: error loading metadata for documentURL:file:
The files I create I believe are fine. I have tried sharing them from a temporary folder and also from a subfolder on the iPad but still get these errors. Any help appreciated.
I'm just trying to display an image that is stored in the local filesystem, but the more I dig into this the more confused I get.
So previously I used this code (it's simplified):
func findImage(name: String) -> UIImage? {
do {
let url = try FileManager.default.url(for: .applicationSupportDirectory,
in: .userDomainMask,
appropriateFor: nil,
create: false)
.appendingPathComponent("MyFolder")
.appendingPathComponent("\(name).png")
guard let image = UIImage(contentsOfFile: url.path) else {
return nil
}
return image
} catch {
print(error.localizedDescription)
}
return nil
}
Notice I create the URL with just .appendingPathComponent() and turning URL to path via url.path.
It works! So what's the question?
In Improving performance and stability when accessing the file system I've read that you better use the new appendingPathComponent(_:isDirectory:), that's good, will do.
Also url.path is deprecated in iOS18. Should I use url.path(percentEncoded:) instead? What should be the value of percentEncoded when accessing the local filesystem?
In this adjacent thread I've read:
Don't use UIImage(contentsOfFile:) either, because it's a path-based API. There's no URL-based equivalent, which is an Apple clue that should be doing something else.
Is this true? Then how should I store and load my images?
Just FYI, I create images like this:
private func generateThumbnail(name: String) {
guard let drawingWidth = canvasGeo?.size.width,
let drawingHeight = canvasGeo?.size.height else { return }
let thumbnailRect = CGRect(x: 0, y: 0, width: drawingWidth, height: drawingHeight)
Task {
UITraitCollection(userInterfaceStyle: .light).performAsCurrent {
let image = self.canvasView.drawing.image(from: thumbnailRect, scale: UIScreen.main.scale)
guard let data = image.pngData() else { return } // -- HERE
do {
try FileManager.default.createDirectory(at: try FileManager.default.url(for: .applicationSupportDirectory,
in: .userDomainMask,
appropriateFor: nil,
create: true)
.appendingPathComponent("MyFolder"),
withIntermediateDirectories: true,
attributes: nil)
let filename = "\(name).png"
let url = try FileManager.default.url(for: .applicationSupportDirectory,
in: .userDomainMask,
appropriateFor: nil,
create: true)
.appendingPathComponent("MyFolder")
.appendingPathComponent(filename)
try data.write(to: url, options: .atomic) // -- and HERE
} catch {
print(error.localizedDescription)
}
}
}
}
My usecase — just save the user's PencilKit Canvas as an image and display it back to him on a different View. I'm on SwiftUI and iOS 16+.
Would be happy to learn the correct way, thanks!
Does Xcode 16 beta 4 include the SDK for iPadOS 18.1 beta, or should I stick with iPadOS 18.0 beta 4/18.0 betas? I want to make sure that I can continue building to my device if I update it to 18.1 beta.
In iOS 18, with the elevated tab bar, the title of the primary view controller in a UISplitViewController automatically hides when the Split View is expanded. However, the title label is still present in the view hierarchy. How to resolve this issue?
Why is the testFieldDidChangeSelection function called three times when the return key is pressed?
Here is what I did
enter text in TextField
press the Return key
The result is that the textFieldDidChangeSelection function is called three times.
I would like to know why.
As a supplement, I asked ChatGPT and the results are below.
At the moment the Return key is pressed: The cursor is updated at the position of the last character entered in the text field.
Insertion of a newline: When the Return key is pressed, a new line is added, and the cursor moves to the beginning of the new line.
Finalization of the edit: Finally, the content of the text field is confirmed, and the position of the cursor is finalized.
Also, is the above answer true?
Been running the public beta for a few days. One significant anomaly. I run an app called Garmin Pilot. It is an aviation Electronic Flight Bag. Since loading the beta, the map rendering in the app has run into a problem.
The two side-by-side photos are the same scene on the map except for the zoom level. At 10NM and above, it's fine. The US Sectional chart is viewable. Drop down to 5NM and the chart disappears. It is the same with other charts in the app.
I am a user of multiple EFB apps and Pilot seems the only one affected. And yes, I reported it to the app developers as well.
In iOS 18 on iPad, the elevated tab bar order is persisted by the system. After reordering the tabs, how can I retrieve the current order of the tabs? and how to override the order programatically.
Has anyone gotten EnvironmentLightingConfigurationComponent to work?
I tried the code from https://developer.apple.com/documentation/realitykit/environmentlightingconfigurationcomponent to prevent a planet from being lit by the environment. My goal is that the side that isn't lit by the star appears pitch black. However, the code seems to have no effect on visionOS 2 and iPadOS 18 (I tried betas 1 through 4, on device, built with Xcode 16 beta 4).
No matter if there is a PointLight or no light at all in the scene, no matter if I use SimpleMaterial or PhysicallyBasedMaterial, no matter if I use a texture or a color on the sphere.
I filed a bug report, it's FB14470954.
Or am I doing something wrong? Here's my code:
var material = PhysicallyBasedMaterial()
if let tex = try? await TextureResource(named: "planet.jpg")
{
material.baseColor = .init(texture: .init(tex))
material.emissiveIntensity = 0
let sphereMesh = MeshResource.generateSphere(radius: 0.5)
let entity = ModelEntity()
entity.components.set(ModelComponent(mesh: sphereMesh, materials: [material]))
entity.position = [-1, 1.0, -1.0]
let envLightingConfig = EnvironmentLightingConfigurationComponent(environmentLightingWeight: 0)
entity.components.set(envLightingConfig)
content.add(entity)
}
I’m having an issue with my published iPad app on the App Store where a selection of users (but not all) are finding they are unable to download my app on their iPad.
The app recently was updated to support only devices Running iOS/iPadOS 17 and also added iPad support as HealthKit is available there now.
The App Store listing correctly shows it as compatible but for some reasons user still see incompatibility messages.
This makes no sense as the app has been full built and tested on iPad and a lot of users are using it fine. All the iPads in question are running ipadOS 17 too. I can only assume this is a bug but I thought I’d post here in case maybe I had an Xcode build setting wrong or something.
Thank You
Hi, the 'Waiting to reconnect to [DEVICE NAME]' error is repeatedly occurring.
Previous preparation error: Developer Mode disabled. To use[DEVICE NAME] for development, enable Developer Mode in Settings → Privacy & Security.
Of course, the developer mode is already turned on and I've used the connection between my devices via XCode until yesterday. But it suddenly happened.
I have several devices(iOS/iPadOS) so I've tried them all, but they are all having the same situations.
What I've tried:
Re-install XCode
Rebooting mac and iPhone
Safe boot my mac
Disable and enable developer mode
Yesterday night, I opened the feedback app, but it kicked me out. When I reopened it, I had to sign back in, but it got stuck on a continuous loading screen. I tried swiping it from the background and reopening it multiple times, but it kept loading indefinitely. I waited for 1 minute, then 3 minutes, but it never stopped. This morning, I checked again to see if my reports had been opened, but the app was still loading.
Hi, here's an example: https://codepen.io/gyurmey2/pen/abgNQdE
Is this even a known issue?
Environment→ ・Device: iPad 9th generation ・OS:**iOS17.5.1 ・Printer model:EPSON PX-S730
Current issues→
01). After canceling a print job in the Print Center, the Print Center screen on the iPad does not close.
02). When the printer is turned on and a new print job is sent, the Print Center shows the ongoing waiting job instead of proceeding with printing.
Problem Description→
The AirPrint feature on an iPad 9th generation running iOS 17.5.1 is being used with an EPSON PX-S730 printer. When sending a print job while the printer is off, the Print Center shows the ongoing printing job. If the print job is canceled in the Print Center, the Print Center screen on the iPad does not close. After turning on the printer and sending the print job again, the Print Center shows the ongoing waiting job.
What I want→
The Print Center screen on the iPad to close automatically after canceling a print job.
Test code:
Note: printController.print response is completed but Print Center status is waiting
let printInfo = UIPrintInfo(dictionary: nil)
printInfo.jobName = "Print Job"
printController.printInfo = printInfo
let pdfURL = Bundle.main.url(forResource: "sample", withExtension: "pdf")!
printController.printingItem = pdfURL
let printer = UIPrinter(url: printerUrl)
printController.print(to: printer, completionHandler: { [self] printController, completed, error in
if(error != nil){
print("error").
}else if completed{
print("completed") //this scenario handles completion response
}else{
print("cancel")
}
})
Environment→ ・Device: iPad 9th generation ・OS:**iOS17.5.1 ・Printer model:EPSON PX-S730
Current issues→
An error message is not returned from the printer if a print job is sent while the printer is off.
Problem Description→
The AirPrint feature on an iPad 9th generation running iOS 17.5.1 is being used with an EPSON PX-S730 printer. When sending a print job while the printer is off, the Print Center shows the ongoing printing job, but the printing cannot be executed because the printer is off.
What I want→
I would like an error to be returned when I submit a printing job while the printer is off.
Test code:
Note: printController.print response is completed but Print Center status is printing
let printInfo = UIPrintInfo(dictionary: nil)
printInfo.jobName = "Print Job"
printController.printInfo = printInfo
let pdfURL = Bundle.main.url(forResource: "sample", withExtension: "pdf")!
printController.printingItem = pdfURL
let printer = UIPrinter(url: printerUrl)
printController.print(to: printer, completionHandler: { [self] printController, completed, error in
if(error != nil){
print("error").
}else if completed{
print("completed"). //this scenario handles completion response
}else{
print("cancel")
}
})
Hello all,
With the release of iPadOS18, I face a strange behavior with the new UITabBar style.
My custom navigation bar is completely broken.
My back arrow is not showed anymore when a VC is pushed.
It reappears when switching iPad on landscape mode.
Some other people face similar behaviors ?
Thank you in advance
I have a TabView with individual tabs containing NavigationSplitViews. On iPadOS 18, when moving the new UI into a sidebar, the title of the first column in the current split view randomly spins its way in and out of view. Is this just a beta bug, or am I doing something wrong? Hard to convey without a recording, but hopefully the screenshots will show what I mean. Thanks.
I'm pursuing a design that necessitates a dual app architecture — using a NavigationStack for compact-sized screens, and a NavigationSplitView for regular-sized screens.
I've encountered what might be a bug in NavigationSplitView on iPadOS 17.x. Or perhaps it's a mistake in my code.
When navigating into nested views (relying on NavigationPath), everything works fine... until I background the app on iPad.
At this point, the navigation stack appears to collapse in the NavigationSplitView detail area — merging the parent and child views.
Adding to the mystery... I can reproduce this bug on iPadOS 17.x. But the problem goes away when running on iPadOS 18.x beta.
Key questions:
Is there a problem in my code?
Should I file a feedback with the Apple SwiftUI team?
If iPadOS 18.x fixes this bug, can I expect a SwiftUI fix to be back-ported to 17.x or earlier?
Steps to reproduce:
Run my sample code on iPadOS simulator.
Navigate to select a color, and then a shape.
Put the app into the background (e.g., go to Home Screen).
Return to app.
What you can expect:
When running on iPadOS 17.x, you'll see that the two most recent views in the stack have merged (meaning the title has changed, and the "back" button has disappeared).
On iPadOS 18.x, you'll see that everything is working fine (title isn't changed, and back button remains available).