swift – UIActivityViewController not working with latest ios 17.2


I have about 40 ipad minis of various ages running an app I developed managed on an mdm. We are upgrading devices so I recently bought 4 ipad mini v6 in December. Everything appears to work except printing. Printing does work via Notes so I think its something with xcode. The user can swipe on a component to print a barcode to a Brother barcode printer. Again, I can print to this computer using Notes. On any of the other 38 older ipad minis, a AirDrop dialog appears like this. enter image description here. but on the new devices it doesn’t work and looks like this enter image description here see the empty bar at the top of the screen. Here is the relevant code. I think it must have something to do with UIActivityViewController. This code works fine on the older devices but not on the newest ones.

        let renderer = UIGraphicsImageRenderer(size: CGSize(width: 1000, height: 400))
        let BarcodeImg = renderer.image { ctx in

            let paragraphStyle = NSMutableParagraphStyle()
            paragraphStyle.alignment = .center

            let attrs: [NSAttributedString.Key: Any] = [
                .font: UIFont.systemFont(ofSize: 65),
                .paragraphStyle: paragraphStyle
            ]
            
            let myQRCode = generateBarcode(from: self.qrCodeLabel.text!)
            myQRCode?.draw(at: CGPoint(x: 15, y: 60))
            
            
            let string = self.qrCodeLabel.text!
            let attributedString = NSAttributedString(string: string, attributes: attrs)
            attributedString.draw(with: CGRect(x: 10, y: 10, width: 1000, height: 400), options: .usesLineFragmentOrigin, context: nil)
            
        }
        qrCodeImage.image = BarcodeImg
        
        let screenSize: CGRect = UIScreen.main.bounds
        let screenWidth = screenSize.width
        let screenHeight = screenSize.height
        
        let vc = UIActivityViewController(activityItems: [BarcodeImg], applicationActivities: [])
        let popover = vc.popoverPresentationController
        popover?.sourceView = view
        popover?.sourceRect = CGRect(x: 32, y: 32, width: screenWidth, height: screenHeight)
        present(vc, animated: true)

Please let me know if you have any ideas what is causing this or how to troubleshoot the issue.

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img