小编Der*_*son的帖子

使用Xcode 7/iOS9无法使用Google Maps API在路径错误时加载优化模型

我正在尝试在我的代码中使用Google Places API自动填充功能.

    import UIKit
import GoogleMaps

class ViewController: UIViewController, GMSMapViewDelegate {

    var placesClient: GMSPlacesClient?

    override func viewDidLoad() {
        super.viewDidLoad()

        placesClient = GMSPlacesClient()

        let filter = GMSAutocompleteFilter()
        filter.type = GMSPlacesAutocompleteTypeFilter.City
        placesClient?.autocompleteQuery("Pizza", bounds: nil, filter: filter, callback: { (results, error: NSError?) -> Void in
            if let error = error {
                print("Autocomplete error \(error)")
            }

            for result in results! {
                if let result = result as? GMSAutocompletePrediction {
                    print("Result \(result.attributedFullText) with placeID \(result.placeID)")
                }
            }
        })

    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行它时,我收到此错误:有CoreData: Failed to …

google-places-api ios9 swift2

6
推荐指数
1
解决办法
2157
查看次数

在自定义视图中使用线程

public class ThreadView extends View {

    Paint paint = new Paint();
    int count;
    Handler uiThread = new Handler();

    public ThreadView(Context context, AttributeSet attrs) {
        super(context, attrs);
        paint.setColor(Color.BLACK);
        paint.setTextSize(80);

        uiThread.post(new Runnable() {
            @Override
            public void run() {
                while(true) {
                    count++;
                    invalidate();
                }
            }
        });
    }

    @Override
    public void onDraw(Canvas canvas) {
        canvas.drawText(count + "", 100, 100, paint);
    }
}
Run Code Online (Sandbox Code Playgroud)

我在自定义视图中看到了针对线程的此解决方案,但是没有用。即使我的循环继续调用invalidate(),也不会继续调用,onDraw() 我还看到了一个解决方案,他们在其中实现了Runnable并覆盖了run(),这是一种更好的方法吗?

multithreading android android-custom-view

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