2017-07-14 68 views
2

我剛剛下載了ARKitExample Projekt(放置對象)。不幸的是有一些錯誤。我是新來的,所以我不知道如何解決它們。有人可以幫我嗎? 我不斷收到錯誤(文件:Utility.swift):Apple ARKit示例代碼

無不是與預期的參數類型兼容 '[字符串:任何]'

代碼:

extension UIImage { 
    func inverted() -> UIImage? { 
     guard let ciImage = CIImage(image: self) else { 
      return nil 
     } 
     return UIImage(ciImage: ciImage.applyingFilter("CIColorInvert", withInputParameters: nil)) 
    } 

返回UIImage的是問題。最後一個參數:「withInputParameters:nil」是問題所在。

回答

9

看來爲CIImage applyingFilter(_:withInputParameters:)方法簽名改變的iOS 11.

的它是:

func applyingFilter(_ filterName: String, withInputParameters params: [String : Any]?) -> CIImage 

現在(如iOS的11):

func applyingFilter(_ filterName: String, parameters params: [String : Any]) -> CIImage 

由於您正在玩ARKit,您必須使用iOS 11,因此您需要將您的代碼更改爲:

extension UIImage { 
    func inverted() -> UIImage? { 
     guard let ciImage = CIImage(image: self) else { 
      return nil 
     } 
     return UIImage(ciImage: ciImage.applyingFilter("CIColorInvert", parameters: [:])) 
    } 
} 
+0

非常感謝。這解決了問題。 – CoderOfTheForce

+0

它沒有工作給我,我改變了代碼: func inverted() - > UIImage? { 後衛讓ciImage = CIImage(圖像:自)否則{ 返回零 } 令反轉= ciImage.applyingFilter( 「CIColorInvert」,withInputParameters:[:]) 返回的UIImage(cgImage:CIContext(選項:無).createCGImage(倒轉,from:倒轉.extent)!) } –