değil, bu yüzden ben oluşturmak göreve içine kullanıcı gönderin:Denemesi sunmak <UIAlertController:> üzerine <ViewController:> kimin görünüm Ben ResearchKit kullanarak bir proje üzerinde çalışıyorum pencere hiyerarşi
let taskViewController = ORKTaskViewController(task: SurveyTask, taskRunUUID: nil)
taskViewController.delegate = self
presentViewController(taskViewController, animated: true, completion: nil)
kullanıcı anket ile bittiğinde, o gider:
func taskViewController(taskViewController: ORKTaskViewController, didFinishWithReason reason: ORKTaskViewControllerFinishReason, error: NSError?) {
switch reason {
case .Completed:
... } Burada
Benönce uyarı gösterme denediğimde bir sorunla karşılaşırsanız ViewController üzerinde ...: UIAlertController sunmak
Denemesi:
taskViewController.dismissViewControllerAnimated(true, completion: nil)
aşağıda hatayı alıyorum ... kimin görünüm penceresi hiyerarşi
yılında I nasıl Herhangi bir fikir değildir ViewController görevden alınmadan önce uyarıyı sunabilir mi?
Ben uyarı için aşağıdaki kullanın:let alertView = UIAlertController(title: "Houps", message: "Could not connect to the server.", preferredStyle: .Alert)
alertView.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil))
presentViewController(alertView, animated: true, completion: nil)
EDIT: kod aşağıdaki gibidir:
if let httpResponse = response as? NSHTTPURLResponse {
print("HTTP response: \(httpResponse.statusCode)")
if httpResponse.statusCode == 201 {
taskViewController.dismissViewControllerAnimated(true, completion: nil)
}
} else {
print("No HTTP response")
let alertView = UIAlertController(title: "Houps", message: "Could not connect to the server.", preferredStyle: .Alert)
alertView.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil))
presentViewController(alertView, animated: true, completion: nil)
}
size uyarı kontrolörü "OK" butonuna tıklamak görünümü denetleyicisi görevden Could itiraz ORKTaskViewController? –
Henüz görevden almak istemiyorum, önce uyarıya geçmek istiyorum. İşten çıkarılma gayet iyi çalışıyor. Sorun, uyarıyı gösteriyor. – asheyla
Evet ve @ j.f. uyarıda "Tamam" a dokunduğunuzda reddetmek için söylüyor. – tktsubota