Индикатор активности запускается, но не останавливается при вызове функции hide. Я пробовал использовать функцию hide в разных местах, и она все еще не скрывает.Скрыть индикатор активности не работает
Скрыть индикатор активности: 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().' to 'self.' – Onichan