小编Hen*_* P.的帖子

如何更改CIDetector方向?

所以我试图CIDetector在Swift中使用文本检测器.当我将手机指向一段文字时,它没有检测到它.但是,如果我将手机转到一边,它可以正常工作并检测到文本.如何更改它以便以正确的相机方向检测文本?这是我的代码:

准备文本检测功能:

func prepareTextDetector() -> CIDetector {
    let options: [String: AnyObject] = [CIDetectorAccuracy: CIDetectorAccuracyHigh, CIDetectorAspectRatio: 1.0]
    return CIDetector(ofType: CIDetectorTypeText, context: nil, options: options)
}
Run Code Online (Sandbox Code Playgroud)

文字检测功能:

func performTextDetection(image: CIImage) -> CIImage? {
    if let detector = detector {
        // Get the detections
        let features = detector.featuresInImage(image)
        for feature in features as! [CITextFeature] {
            resultImage = drawHighlightOverlayForPoints(image, topLeft: feature.topLeft, topRight: feature.topRight,
                                                        bottomLeft: feature.bottomLeft, bottomRight: feature.bottomRight)                
            imagex = cropBusinessCardForPoints(resultImage!, topLeft: feature.topLeft, topRight: feature.topRight, bottomLeft: feature.bottomLeft, bottomRight: feature.bottomRight)
        }
    }
    return resultImage …
Run Code Online (Sandbox Code Playgroud)

ios swift cidetector

4
推荐指数
1
解决办法
1560
查看次数

类型'Any'在Swift 3 Xcode 8中没有下标成员

我正在尝试将我的项目转换为Swift 3并继续收到此错误.我已经解决了所有其他错误,但这个错误.我看到其他一些人遇到了问题,但我是JSON的新手,所以我不理解它们.任何帮助将不胜感激.

这是我的代码:

class func fetchPriceForSymbol(_ symbol: String, completion:@escaping (_ stock: StockPrice) -> ()) {

    DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.default).async {

        let url = URL(string: "http://finance.yahoo.com/webservice/v1/symbols/\(symbol)/quote?format=json")
        let data = try? Data(contentsOf: url!)

        do {
            //let object = try JSONSerialization.jsonObject(with: data!, options: .allowFragments)
            let object = try! JSONSerialization.jsonObject(with: data!)
            if let dictionary = object as? [String: AnyObject] {
                let title = object["list"] as! NSDictionary
                let title2 = title["resources"] as AnyObject!
                let title3 = title2[0] as AnyObject!
                let title4 = title3["resource"] as AnyObject!
                let fields …
Run Code Online (Sandbox Code Playgroud)

xcode ios swift

4
推荐指数
1
解决办法
1万
查看次数

为什么iAd不工作?

我已经尝试了所有尝试让iAd在我的应用程序中工作,但没有任何东西出现.我正在努力做到这一点,我在线self.canDisplayBannerAds = true下,viewDidLoad但没有任何工作.我无法得到任何东西.我已将iAd导入并添加到我的应用中.任何帮助将不胜感激.

ios iad swift

-1
推荐指数
1
解决办法
182
查看次数

标签 统计

ios ×3

swift ×3

cidetector ×1

iad ×1

xcode ×1