Harley-xk / MaLiang

iOS painting and drawing library based on Metal. 神笔马良有一支神笔(基于 Metal 的涂鸦绘图库)
MIT License
1.47k stars 209 forks source link

部分iPad上apple pencil不能在画布上使用,请问有其他朋友遇到过吗? #140

Open zhudi12358 opened 1 year ago

zhudi12358 commented 1 year ago

部分iPad上apple pencil不能在画布上使用,请问有其他朋友遇到过吗? 我自己无法复现,但是有部分线上用户反馈,iPad上apple pencil不能在画布上使用,画布以外的位置都正常。

lexuanquynh commented 1 year ago

Use it for check:

//
//  UIDevice+Ex.swift
//  PrescriptionReception
//
//  Created by Le Xuan Quynh on 21/09/2023.
//

import UIKit

// supportPencil
extension UIDevice {
    /*
     You can use Apple Pencil (2nd generation) with these iPad models:
     iPad mini (6th generation)
     iPad Air (4th generation and later)
     iPad Pro 12.9-inch (3rd generation and later)
     iPad Pro 11-inch (1st generation and later)

     You can use Apple Pencil (1st generation) with these iPad models:
     iPad mini (5th generation)
     iPad (6th, 7th, 8th, and 9th generation)
     iPad (10th generation)*
     iPad Air (3rd generation)
     iPad Pro 12.9-inch (1st and 2nd generation)
     iPad Pro 10.5-inch
     iPad Pro 9.7-inch
     */
    var isSupportPencil: Bool {   
        // if simulator always return false
        #if targetEnvironment(simulator)
        return false
        #endif    
        // return self.modelName == "iPad mini (6th generation)"
        // || self.modelName == "iPad Air (4th generation)"
        // || self.modelName == "iPad Pro 12.9-inch (3rd generation)"
        // || self.modelName == "iPad Pro 11-inch (1st generation)"
        // || self.modelName == "iPad mini (5th generation)"
        // || self.modelName == "iPad (6th generation)"
        // || self.modelName == "iPad (7th generation)"
        // || self.modelName == "iPad (8th generation)"
        // || self.modelName == "iPad (9th generation)"
        // || self.modelName == "iPad Air (3rd generation)"
        // || self.modelName == "iPad Pro 12.9-inch (1st generation)"
        // || self.modelName == "iPad Pro 12.9-inch (2nd generation)"
        // || self.modelName == "iPad Pro 10.5-inch"
        // || self.modelName == "iPad Pro 9.7-inch"
        // using contains
        return ["iPad mini (6th generation)",
                "iPad Air (4th generation)",
                "iPad Pro 12.9-inch (3rd generation)",
                "iPad Pro 11-inch (1st generation)",
                "iPad mini (5th generation)",
                "iPad (6th generation)",
                "iPad (7th generation)",
                "iPad (8th generation)",
                "iPad (9th generation)",
                "iPad Air (3rd generation)",
                "iPad Pro 12.9-inch (1st generation)",
                "iPad Pro 12.9-inch (2nd generation)",
                "iPad Pro 10.5-inch",
                "iPad Pro 9.7-inch"].contains(self.modelName)
    }

    var modelName: String {
        return UIDevice.current.name
    }
}