小编Kha*_*lad的帖子

根据屏幕大小更改UICollectionView单元格大小

我能够使用下面的函数更改collectionView单元格大小但是如何使此功能适用于不同的屏幕大小.所以,例如我希望iPad上的高度和宽度不同,iPhone就有办法做到这一点

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
            let width = UIScreen.main.bounds.width
            let height = UIScreen.main.bounds.height
            return CGSize(width: (width/5.5), height: (height/4.5))

        }
Run Code Online (Sandbox Code Playgroud)

ios uicollectionview uicollectionviewcell uicollectionviewlayout swift

0
推荐指数
1
解决办法
808
查看次数

使用MBProgressView取消按钮

我正在尝试将取消按钮与MBProgressView一起使用。我收到错误消息“无法将类型'()'的值转换为预期的参数类型'选择器'”

hud.button.addTarget(hud.progressObject, action: cancelButton(), for: .touchUpInside)
Run Code Online (Sandbox Code Playgroud)

我也尝试这样做:

hud.button.addTarget(hud.progressObject, action: #selector(cancelButton), for: .touchUpInside)
Run Code Online (Sandbox Code Playgroud)

我得到了错误“ #selector的参数不能引用本地函数'cancelButton()'”。

谁能向我解释我在做什么错?

cancelButton应该在viewDidLoad中,或者至少我需要找到一种方法来访问viewDidload内的内容,因为我需要使用hud和snapshot.progress来取消下载:

   override func viewDidLoad() {
        super.viewDidLoad()

        let appdelegate = UIApplication.shared.delegate as! AppDelegate
        appdelegate.orintation = UIInterfaceOrientationMask.allButUpsideDown
        if book?.bookPath !=  book?.bookPath {
            print("HERE \(book?.bookPath)")
            loadReader(filePaht: (book?.bookPath)!)
        } else {
            let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
            let strName = book?.id
            let filePath = "\(documentsPath)/"+strName!+".pdf"
            let fileManager = FileManager.default

            if fileManager.fileExists(atPath: filePath) {
                loadReader(filePaht: filePath)
                return;
            }

            print("DOWNLOAD #1")

            let reference = FIRStorage.storage().reference(forURL: (self.book?.bookURL)!)
            let downloadTask =  reference.data(withMaxSize: 50 …
Run Code Online (Sandbox Code Playgroud)

selector mbprogresshud swift

0
推荐指数
1
解决办法
866
查看次数