2023年04月復(fù)盤篇:iOS問題解決經(jīng)驗總結(jié)復(fù)盤

??

目錄
一、編譯報錯/bin/sh: bad interpreter: Operation not permitted Command PhaseScriptExecution failed with a nonzero exit code
二、如何獲取UISlider滑桿的中心位置

一、編譯報錯:xx/bin/sh: bad interpreter: Operation not permittedCommand PhaseScriptExecution failed with a nonzero exit code

問題紀要:
由于想看看一下SJVideoPlayer框架源碼以及示例,結(jié)果下載之后報錯/bin/sh: bad interpreter: Operation not permitted Command PhaseScriptExecution failed with a nonzero exit code,嘗試pod install 以及pod updata 依然無效,還是報這個錯誤好奇怪,也不知道為何會報沒有執(zhí)行權(quán)限的問題

解決辦法:在工程根目錄,用這個命令來去除這個屬性:
xattr -d -r com.apple.quarantine ./*

二、如何獲取UISlider滑桿的中心位置

效果圖.gif

分享這個的解決方案思路:

在分析之前,先安利一個UI調(diào)試庫(LookinServer) ,開發(fā)必備神器。反正我經(jīng)常會用到這個。不得不說這個真的很實用。在Podfile中導(dǎo)入

  # UI 調(diào)試庫
  pod 'LookinServer', :git => 'https://gitee.com/chuansong16/LookinServer.git', :configurations => ['Debug']

其次就是需要下載一個Lookin的軟件。從而查看他的層次結(jié)果,從而在結(jié)構(gòu)中我們能發(fā)現(xiàn)其底層是用UIImageView去承載滾動的那個軸。

image.png

具體實現(xiàn)如下代碼:

     /// ***slider初始化xxx代碼,然后添加事件
        slider.addTarget(self, action:#selector(seliderProgress(_:)) , for: .valueChanged)

    // 美顏度進度事件
     @objc private func seliderProgress(_ slider: UISlider) {
         setupBeautyProgressConstraints()
         let integerValue = Int(slider.value)
         beautySlider.value = Float(integerValue)
         beautyProgressLabel.text =  "\(integerValue)"
        print("===== value:\(integerValue)")
     }
    /// 更新滑桿值label的約束
   private func setupBeautyProgressConstraints(){
        if let elementClass = NSClassFromString("_UISlideriOSVisualElement"),
           let imageClass = NSClassFromString("UIImageView"){
            for tempView in beautySlider.subviews where tempView.isKind(of: elementClass) {
                for tempImgView in tempView.subviews where tempImgView.isKind(of: imageClass) {
                    beautyProgressLabel.snp.remakeConstraints{
                        $0.centerX.equalTo(tempImgView.snp_centerX)
                        $0.centerY.equalTo(tempImgView.snp_centerY).offset(-20)
                    }
                }
            }
        }
    }
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容