活动指示器启动,但在调用隐藏功能时不会停止。我试过把隐藏功能放在不同的地方,但它仍然不隐藏。隐藏活动指示器不起作用
隐藏活动的指标:Q0ViewController().hideActivityIndicator(self.view)
我使用的快捷实用功能在这里找到: 开始活动的指标查询后https://github.com/erangaeb/dev-notes/blob/master/swift/ViewControllerUtils.swift
override func viewDidLoad() {
super.viewDidLoad()
Q0ViewController().showActivityIndicator(self.view)
self.locationManager.delegate = self //location manager start
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.requestWhenInUseAuthorization()
self.locationManager.startUpdatingLocation()
}
隐藏活动的指标:
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
CLGeocoder().reverseGeocodeLocation(manager.location, completionHandler: { (placemarks, error) -> Void in
if (error != nil) {
println("Error:" + error.localizedDescription)
//return
}
if placemarks.count > 0 {
let pm = placemarks[0] as CLPlacemark
self.displayLocationInfo(pm)
currentLoc = manager.location
currentLocGeoPoint = PFGeoPoint(location:currentLoc)
var query = PFQuery(className:"test10000")
query.whereKey("RestaurantLoc", nearGeoPoint:currentLocGeoPoint, withinMiles:100) //filter by miles
query.limit = 1000 //limit number of results
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]!, error: NSError!) -> Void in
if objects != nil {
unfilteredRestaurantArray = objects
originalUnfilteredArray = objects
println(objects)
} else {
println("error: \(error)")
}
Q0ViewController().hideActivityIndicator(self.view) //HIDE
}
} else {
println("error: \(error)")
}
})
}
这不是主队列的问题,因为dispatch_after(DISPATCH_TIME_NOW, dispatch_get_main_queue(), {()->() in
不能解决问题。
谢谢,但我似乎得到一个错误与类的实例[画面](HTTP变量://i.imgur.com/E93Zt2r.png) – Onichan
看起来像你非常接近。只需将'Q0ViewController()。'更改为'self.' – Onichan