Discuss hardware-specific topics related to iPad.

Posts under iPad tag

126 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

AdMob inline adaptive banner in NavigationSplitView sidebar
TL;DR How to implement AdMob inline adaptive banner ad in NavigationSplitView's sidebar on iPad with SwiftUI, so it takes the entire width of its parent and the view's height adjusts to the ad's height? Details I'm trying to insert an AdMob inline adaptive banner ad in the sidebar of a NavigationSplitView on iPad. As I'm using SwiftUI, I tried to replicate the implementation from this Google example. One problem is that the example is for an adaptive anchor banner ad—not what I'm looking for. I've made a few attempts over the past few days, with varying results. I can't seem to make it truly adaptive. Two attempts that display the ad but with fixed size are presented below. Attempt 1 struct InlineAdaptiveBannerAdView: UIViewControllerRepresentable { func makeUIViewController(context: Context) -> some UIViewController { let viewController = UIViewController() let adSize = GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(280, 150) let bannerView = GADBannerView(adSize: adSize) bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716" bannerView.rootViewController = viewController let request = GADRequest() request.scene = UIApplication.shared.connectedScenes.first as? UIWindowScene bannerView.load(request) viewController.view.addSubview(bannerView) return viewController } func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {} } I didn't know how to get the width of the sidebar programmatically, so I set it to 320 with .navigationSplitViewColumnWidth() and set the ad width to 280 (adjusted for padding). This code displays the ad nicely (at least along X-axis), but the size is fixed. Attempt 2 struct InlineAdaptiveBannerAdView: UIViewControllerRepresentable { // viewWidth is set to .zero in the Google sample @State private var viewWidth: CGFloat = CGFloat(280.0) private let bannerView = GADBannerView() private let adUnitID = "ca-app-pub-3940256099942544/2934735716" func makeUIViewController(context: Context) -> some UIViewController { let bannerViewController = BannerViewController() bannerView.adUnitID = adUnitID bannerView.rootViewController = bannerViewController bannerView.delegate = context.coordinator bannerView.translatesAutoresizingMaskIntoConstraints = false // Removed the constraints from the sample bannerViewController.view.addSubview(bannerView) bannerViewController.delegate = context.coordinator return bannerViewController } func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { guard viewWidth != .zero else { return } bannerView.adSize = GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(viewWidth, 150) let request = GADRequest() request.scene = UIApplication.shared.connectedScenes.first as? UIWindowScene bannerView.load(request) print("View height: \(uiViewController.view.frame.height)") } func makeCoordinator() -> Coordinator { Coordinator(self) } class Coordinator: NSObject, BannerViewControllerWidthDelegate, GADBannerViewDelegate { let parent: InlineAdaptiveBannerAdView init(_ parent: InlineAdaptiveBannerAdView) { self.parent = parent } // MARK: BannerViewControllerWidthDelegate methods func bannerViewController(_ bannerViewController: BannerViewController, didUpdate width: CGFloat) { parent.viewWidth = width } // MARK: GADBannerViewDelegate methods func bannerViewDidReceiveAd(_ bannerView: GADBannerView) { print("Did receive ad") print("Ad height: \(bannerView.adSize.size.height)") } func bannerView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: Error) { print("Did not receive ad: \(error.localizedDescription)") } } } protocol BannerViewControllerWidthDelegate: AnyObject { func bannerViewController(_ bannerViewController: BannerViewController, didUpdate width: CGFloat) } class BannerViewController: UIViewController { weak var delegate: BannerViewControllerWidthDelegate? override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) delegate?.bannerViewController(self, didUpdate: view.frame.inset(by: view.safeAreaInsets).size.width) } override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { coordinator.animate { _ in // Do nothing } completion: { _ in self.delegate?.bannerViewController(self, didUpdate: self.view.frame.inset(by: self.view.safeAreaInsets).size.width) } } } If I leave the default .zero for viewWidth, the whole process doesn't get through guard viewWidth != .zero else { return }. With viewWidth set to 280, the ad shows, but the size is never updated. Both viewDidAppear(_:) and viewWillTransition(to:with:) never get called, even if the ad gets displayed, so the width is never updated. As for height, according to Google developer's guide (which I can't link to on this forum): The height is either zero or maxHeight, depending on which API you're using. The actual height of the ad is made available when it's returned. So, I can read the ad's height when it is presented, but I still don't know how to really update the view's size. My brain is fried. Am I missing something very simple and obvious here?
1
0
514
Nov ’23
Allow Display Mode Changes
When you connect an external display via USB-C to an iPad, that displays shows in iPadOS via Settings -> Display and Brightness -> Name of Display. There is an option called 'Allow Display Mode Changes' for an external display which is described as follows: When this is on, the display mode will change to match the dynamic range and frame rate of the content you're viewing. This may result in flickering or long periods of black whenever content changes. Does anyone know how this functionality works and how to support it for an iPadOS App? In my tests the iPad always outputs at a frame rate of 60fps or sometimes 59.94fps. If the video I am playing back from an AVPlayer is at 25fps the external display stays at 60fps both with 'Allow Display Mode Changes' toggled on/off. Given that it's meant to 'match frame rate of content' I would expect the external display to change from 60fps -> 25fps. I can not find any documentation about this feature and what AV Frameworks it talks to or gets it's frame rate information from. If anyone has any idea or has experimented with it and learnt something that would be much appreciated.
0
0
616
Nov ’23
Wrong Video Aspect Ratio
Hello. I'm having problems with a narrow video aspect ratio displayed on an iPad Air. In an outlet labeled ImagePreviewOutlet I want to display a video feed from the iPad camera facing the user. So basically the user will see their own face. I did all the necessary moves in the Story Board and in the code and I got what I wanted. Except it is in the wrong Aspect Ratio. The image doesn't fill the screen of the iPad even though the dimensions of the ImagePreviewOutlet does. It's narrow, showing white space on either side of the video. I want a wider aspect ratio. I understand that the iPad has 2 ratios : 4:3 and 16:9. Can anybody help me? I can supply the code that I'm using but I don't want my first post to be overwhelming. Thank you for your time. JR
1
0
442
Nov ’23
Need help of my Verizon iPad 3,3 ( GSM )
My iPad 3 have replaced it battery and now it needs to restore to its firmware ( iOS 9.3.6 ) but before that the sim card cable is broken and I already replaced it. Now it's doesn't letting me to restore to the iPad 3,3 software cause it's not the correct os ( itunes app report ). But the wifi model is 3,1 and this thing had its 4g black atenna section, still using verzion sim but doesn't let me restore to the iPad 3,3 software.
1
1
266
Nov ’23
UITextView Apple Pencil crash
I used Apple Pencil to input text on UITextView, but the program crashed when I long pressed and tried to use the insert function. warning: Module "/Users/baochengzhu/Library/Developer/Xcode/iOS DeviceSupport/iPad14,1 17.0.3 (21A360)/Symbols/usr/lib/libobjc.A.dylib" uses triple "arm64e-apple-ios17.0.0", which is not compatible with the target triple "arm64-apple-ios11.0.0". Enabling per-module Swift scratch context who can help me ?
0
0
299
Nov ’23
HLS/Fairplay - Terminated due to signal 9 - Only when running "Mac (designed for iPad)" from xcode
My project is a TV player app for HLS streams with fairplay encryption. It is made on swiftUI for iPhone and iPad, it is in production. I have enabled the target "Mac (Designed for iPad)" in the project settings, and It is working perfectly on Mac M1 chips when running the app from the Mac AppStore. The Mac version has never been main main focus, but it is nice to have it working so easily. However when I run the app from Xcode, by selecting "My Mac (Designed for iPad)", everytime AVPlayer wants to start playback I am ejected from the app and the only thing I get from the logcat is: Message from debugger: Terminated due to signal 9 Why? And Why does it work when running the app published on the appstore? I was able to debug a bit and identify which line of code triggers the issue but I am still stuck: I am using an AVAssetResourceLoaderDelegate to load the Fairplay Keys instead of the default one (because I need some authentication parameters in the HTTP headers to communicate with the DRM Proxy). So, in the process I am able to request SPC data and CKC (I have verified the data), and then when the loadingRequest.finishLoading() is called.. BOOM the app is terminated and it triggers the log Message from debugger: Terminated due to signal 9. I am sharing the delegate method from the AVAssetResourceLoaderDelegate where it happens. This has been written a while ago and is running fine on all devices. If you are not used to this delegate, it is used by AVPlayer whenever a new mediaItem is set with the method: AVPlayer.replaceCurrentItem(with: mediaItem) func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool { guard let dataRequest = loadingRequest.dataRequest else { return false } getFairplaycertificate { data, _ in // Request Server Playback Context (SPC) data guard let certificate = data, let contentIdData = (loadingRequest.request.url?.host ?? "").data(using: String.Encoding.utf8), let spcData = try? loadingRequest.streamingContentKeyRequestData( forApp: certificate, contentIdentifier: contentIdData, options: [AVContentKeyRequestProtocolVersionsKey: [1]] ) else { loadingRequest.finishLoading(with: NSError(domain: "tvplayer", code: -1, userInfo: nil)) print("⚠️", #function, "Unable to get SPC data.") return false } // Now the CKC can be requested let networkId = loadingRequest.request.url?.host ?? "" self.requestCKC(spcData: spcData, contentId: networkId) { ckc, error in if error == nil && ckc != nil { // The CKC is correctly returned and is sent to AVPlayer. Stream is decrypted dataRequest.respond(with: ckc!) loadingRequest.contentInformationRequest?.contentType = AVStreamingKeyDeliveryContentKeyType loadingRequest.finishLoading() // <--- THIS LINE IS GUILTY!!! } else { print("⚠️", #function, "Unable to get CKC.") loadingRequest.finishLoading(with: error) } } return true } return true } If I comment loadingRequest.finishLoading() or if I replace it by: loadingRequest.finishLoading(with: error), the app is not terminated but my decryption keys are not loaded. That's the only clue I have so far. Any help would be appreciated. What should I look for? Is there a way to get a detailed error stacktrace? Thanks.
1
2
604
Nov ’23
Are PWA App Data and Cookies Cleared When iPad Turned Off for Long Periods
Hi, Getting reports from a client that they are being asked to re-login to their PWA (saved to their home screen) whenever they turn off their iPads for periods of 1-2hrs and then turn it back on again. Just noting, this isn't related to the 7 day cap on cookie data in webkit as we've already addressed this. I've tested just turning it off for a few minutes on a standard iPhone with iOS17 but don't experience the same issue. Does anyone know if it is part of iOS's device restart to clear PWA cookies etc. if the device has been off for a long time? The only other avenue I can think of is that the client's devices may have some MDM setting for this. Thanks in advance.
1
0
703
Oct ’23
SwifftUI iPadOS landscape view bug
Hi there, I am currently developing an app for iPhone and iPad. I made a sidebar with various items which are linked to other pages via NavigationLink. The problem is, that as soon as I scroll down, the app crashes. This is only happening in landscape mode on the iPad. What am I doing wrong? Thank you for your help! Here is my code: var body: some View { NavigationView { List { Group { NavigationLink(destination: Acetylsalicylsaeure()){ Image("AcetylsalicylsaeureMediLabel") .resizable() .frame(width:60, height: 30) Text("Acetylsalicylsäure") } NavigationLink(destination: Amiodaron()){ Image("AmiodaronMediLabel") .resizable() .frame(width:60, height: 30) Text("Amiodaron") } NavigationLink(destination: Atropin()){ Image("AtropinMediLabel") .resizable() .frame(width:60, height: 30) Text("Atropin") } NavigationLink(destination: Butylscopolamin()){ Image("ButylscopolaminMediLabel") .resizable() .frame(width:60, height: 30) Text("Butylscopolamin") } NavigationLink(destination: Dimenhydrinat()){ Image("DimenhydrinatMediLabel") .resizable() .frame(width:60, height: 30) Text("Dimenhydrinat") } NavigationLink(destination: Dimentinden()){ Image("DimentindenMediLabel") .resizable() .frame(width:60, height: 30) Text("Dimentinden") } NavigationLink(destination: Epinephrin()){ Image("EpinephrinMediLabel") .resizable() .frame(width:60, height: 30) Text("Epinephrin") } NavigationLink(destination: Esketamin()){ Image("EsketaminMediLabel") .resizable() .frame(width:60, height: 30) Text("Esketamin") } } // More NavigationLinks... Group { NavigationLink(destination: Midazolam()){ Image("MidazolamMediLabel") .resizable() .frame(width:60, height: 30) Text("Midazolam") } NavigationLink(destination: Naloxon()){ Image("NaloxonMediLabel") .resizable() .frame(width:60, height: 30) Text("Naloxon") } NavigationLink(destination: Paracetamol()){ Image("ParacetamolMediLabel") .resizable() .frame(width:60, height: 30) Text("Paracetamol") } NavigationLink(destination: Prednisolon()){ Image("PrednisolonMediLabel") .resizable() .frame(width:60, height: 30) Text("Prednisolon") } NavigationLink(destination: Salbutamol()){ Image("SalbutamolMediLabel") .resizable() .frame(width:60, height: 30) Text("Salbutamol") } NavigationLink(destination: Sauerstoff()){ Image("SauerstoffMediLabel") .resizable() .frame(width:60, height: 30) Text("Sauerstoff") } NavigationLink(destination: Urapidil()){ Image("UrapidilMediLabel") .resizable() .frame(width:60, height: 30) Text("Urapidil") } NavigationLink(destination: Vollelektrolytloesung()){ Image("VollelektrolytloesungMediLabel") .resizable() .frame(width:60, height: 30) Text("Vollelektrolytlösung") } } } .listStyle(SidebarListStyle()) .navigationTitle("Medikamente") BackgroundMedikamente() } } }
0
0
365
Oct ’23
App crashes after updating to iOS 16 and above
I have been solving a mystery for some time now, when after updating to iOS 16+ or 17+ the application crashes at some moments. I can't figure out what is causing this. it didn't happen to me in previous versions of iOS. Can you advise me according to the log from the device what could be causing this? PCI Full-2023-10-09-131124.ips Thank you
0
0
409
Oct ’23
RTSP live video stream by cable doesn't work after update to iPad OS 17.
Hard/Software: iPad 7, Ipad OS 17.0.3, MobileVLCKit, SDP/RTSP stream, USB/Ethernet cable. Description: I have an iPad application for live video streaming. From a security point of view, it should work via cable (USB/Ethernet). This application uses MobileVLCKit player to play videos. Videos are available via a URLs with an IP address and use the SDP/RTSP format (url example: http://172.20.129.69/stream/sdp). Code example: let camUri="http://172.20.129.69/stream/sdp" let options = ["--network-caching=100"] var players: [VLCMediaPlayer] = [] players.append(VLCMediaPlayer(options: options)) let media = VLCMedia(url: camUri) players[0].media = media players[0].drawable = centerView players[0].play() Problem: The application worked on various iPads with iPad OS 16 and lower (using cable or Wi-Fi). After updating to iPad OS 17, the application no longer works via cable. What could be the problem and how to fix it?
1
0
642
Oct ’23
Background beacon detection is delayed only on recent iPads
I am developing an app that detects iBeacons and takes action. The problem is that some iPads do not launch the app even though the iBeacon is detected when the iPad is locked. This app works as follows. Start monitoring the iBeacon using startMonitoring(). When the iPad detects the iBeacon, the didEnterRegion delegate is called. The didDetermineState delegate is then called. Inside the didDetermineState delegate my app does the required behavior. The app works on iPhones and some iPads as soon as it detects an iBeacon, whether the app is in the foreground, in the background, or when the device is locked (this is expected behavior). However, some other iPads delay calling the didEnterRegion delegate only when the device is locked. When the device is locked, the didEnterRegion delegate is called with a delay at an unspecified time, anywhere from a few seconds to 20 minutes. The didEnterRegion delegate is called immediately if foreground or background. Also, when the didEnterRegion delegate call is delayed, if you press the iPad's home button to unlock it and the home screen is displayed, the didEnterRegion delegate will be called immediately. Also, the didEnterRegion delegate is called immediately if the iPad is connected to power, even in the locked state. This issue only occurs when the iPad is on battery power and locked. I've tried it on several devices, and the difference seems to be due to the iPad generation, not the OS version. Is there a possibility that the new generation iPad's energy saving feature may delay the background startup of apps when the iPad is locked? A model that operates immediately upon detecting an iBeacon ・iPhone 13mini (iOS 17.0.3) ・iPhone 8 (iOS 17.0.3) ・iPad 6th generation (iPadOS 16.7) Models where didEnterRegion is delayed even if iBeacon is detected ・iPad 8th generation (iPadOS 16.2) ・iPad 8th generation (iPadOS 16.7) ・iPad 9th generation (iPadOS 16.2) Have such cases been reported? Also, how can such phenomena be avoided? Thank you.
0
0
325
Oct ’23
Fixing a CommandMenu causing UIMenuController - unrecognized selector
I have a SwiftUI app I have enabled to run on M1 Macs (Designed for iPad). It uses the new SwiftUI lifecycle. I've just added a CommandMenu to the main WindowGroup. On the iPad these commands, whether clicked in the menu or initiated by a keyboard shortcut work as expected on the iPad. However, my iMac, the app crashes. The error says Application Specific Information: Crashing on exception: -[UIMenuController propertyList]: unrecognized selector sent to instance 0x12250b1e0 This is what the CommandMenu looks like WindowGroup { ... }.commands {         CommandMenu(LocalizedStringKey("Categories")) {             Button(action:{                 appConfiguration.currentPage = Page.books             }) {                 Label(LocalizedStringKey(BookListing.title), systemImage: BookListing.icon)             }             .keyboardShortcut("b", modifiers: [.control])             Button(action:{                 appConfiguration.currentPage = Page.tags             }) {                 Label(LocalizedStringKey(Tags.title), systemImage: Tags.icon)             }             .keyboardShortcut("t", modifiers: [.control])             Button(action:{                 appConfiguration.currentPage = Page.settings             }) {                 Label(LocalizedStringKey(Settings.title), systemImage: Settings.icon)             }             .keyboardShortcut("s", modifiers: [.control])         }     } AppConfiguration is an ObservableObject and setting currentPage is how to programmatically navigate the TavView. Is there anything I am doing wrong? Is there a bug someone knows about that I could be hitting? Here's the relevant part of the stack if that can help shed some light on what's gone wrong. Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 AppKit 0x191895514 -[NSApplication _crashOnException:] + 324 1 AppKit 0x19189550c -[NSApplication _crashOnException:] + 316 2 AppKit 0x19189522c -[NSApplication reportException:] + 580 3 AppKit 0x19193f708 uncaughtErrorProc + 156 4 HIToolbox 0x1975b10bc DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1696 5 HIToolbox 0x1975b02dc SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 356 6 HIToolbox 0x1975c6750 SendEventToEventTarget + 40 7 HIToolbox 0x197627310 SendHICommandEvent(unsigned int, HICommand const*, unsigned int, unsigned int, unsigned char, void const*, OpaqueEventTargetRef*, OpaqueEventTargetRef*, OpaqueEventRef**) + 416 8 HIToolbox 0x19764c44c SendMenuCommandWithContextAndModifiers + 56 9 HIToolbox 0x19764c3dc SendMenuItemSelectedEvent + 352 10 HIToolbox 0x19764c208 FinishMenuSelection(SelectionData*, MenuResult*, MenuResult*) + 100 11 HIToolbox 0x19764cbc8 MenuSelectCore(MenuData*, Point, double, unsigned int, OpaqueMenuRef**, unsigned short*) + 560 12 HIToolbox 0x19764c8e8 _HandleMenuSelection2 + 416 13 AppKit 0x1916b4ce4 _NSHandleCarbonMenuEvent + 300 14 AppKit 0x1916b4ac4 _DPSEventHandledByCarbon + 68 15 AppKit 0x191516bc4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3280 16 AppKit 0x1915085f0 -[NSApplication run] + 596 17 AppKit 0x1914d9d08 NSApplicationMain + 1132 18 AppKit 0x1917afdd0 _NSApplicationMainWithInfoDictionary + 24 19 UIKitMacHelper 0x1a423aa7c UINSApplicationMain + 1276 20 UIKitCore 0x1b68d59f8 UIApplicationMain + 164 21 SwiftUI 0x1cc162374 closure #1 in KitRendererCommon(_:) + 164 22 SwiftUI 0x1cc1622cc runApp<A>(_:) + 252 23 SwiftUI 0x1cba55560 static App.main() + 128
3
0
1.8k
Oct ’23
Music app on my iPad not working as intended
Hi! I have a 4th gen iPad Air with 17.1 beta 1 version loaded on it. When trying to edit a playlist, every time I remove a song, it always goes back to the top of my playlist, causing me to have to scroll back down. But that’s not the only problem; once I do get back to where I was in my list, and before I can do anything else it will just go back to the top of my list without me doing anything! it doesn’t happen every time but enough times to make it hard for me to continue what I’m trying to do. I have closed the app several times, and even restarted my iPad a few times but still the issues persist! Help? 😅
0
0
402
Oct ’23