Reputation: 63
I am using UIPrinterPickerController for selecting any one printer in printer list but UIPickerController doesn't open when I am running code to IPAD simulator but this same code I will run to IPHONE simulator is correct and show my all simulator printer and I can select any printer and get printer name as well as there url.
let pickerController = UIPrinterPickerController(initiallySelectedPrinter: nil)
if UIDevice.current.userInterfaceIdiom == .pad {
pickerController.present(animated: true) {(controller,completed,error) in
if completed == true {
let ipadprintername = controller.selectedPrinter!.displayName
}
}
}else{
pickerController.present(animated: true){(controller, completed,error)in
if completed == true {
let iphoneprintername = controller.selectedPrinter!.displayName
}
}
}
Upvotes: 2
Views: 1073
Reputation: 63
if UIDevice.current.userInterfaceIdiom == .pad {
let pickerController = UIPrinterPickerController(initiallySelectedPrinter: nil)
pickerController.present(from: CGRect(x: 400, y: 200, width: 0, height: 0), in: view, animated: true){( controller,completed,error) in
if completed == true {
let printername = controller.selectedPrinter!.displayName
}
}
}else{
let pickerController = UIPrinterPickerController(initiallySelectedPrinter: nil)
pickerController.present(animated: true) { (controller, completed, error) in
if completed == true {
let printername = controller.selectedPrinter!.displayName
}
}
}
Upvotes: 4