我已經創建了請求,並且我想在彈出對話框時收到成功消息。這裏是我的代碼:popViewController在iOS中的NSURLSessionDataTask塊中不起作用
NSURLSession *session = [NSURLSession sharedSession];
NSString *baseURLRequest = [NSString stringWithFormat:@"%@/email_addr=%@",mySession.baseURL,self.txtEmail.text];
NSURLSessionDataTask *dataTask = [session dataTaskWithURL:[NSURL URLWithString:baseURLRequest] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSDictionary *dict = [json objectForKey:@"result"];
NSString *msg = [dict objectForKey:@"msg"];
if ([[dict objectForKey:@"status"] isEqualToString:@"success"])
{
dispatch_async(dispatch_get_main_queue(), ^{
[self showMesssgeonAlert:@"Success"];
[self hideProgress];
[self.navigationController popViewControllerAnimated:YES];
});
}
else
{
}
}];
[dataTask resume];
下面不工作,
[self.navigationController popViewControllerAnimated:YES];
有沒有人有一個想法,爲什麼發生這種情況? UINavigation controller
對於viewControllers
也是相同的。請幫助我,謝謝。
檢查是否([[dict objectForKey:@「status」] isEqualToString:@「success」])成功並檢查自己是否自己.navigationcontroller不爲零 – Rajesh
檢查'self.navigationController'是否爲零 –
if self showMesssgeonAlert:@「Success」];和[self hideProgress];方法被稱爲善意檢查你的navigationController可能是零。你有嵌入導航控制器的故事板。 – luckyShubhra