เมื่อคลิกปุ่มส่งในแอปพลิเคชันของฉัน SubmitViewController
จะถูกนำเสนอเหนือตัวควบคุมมุมมองที่ใช้งานอยู่เพื่อแสดงความคืบหน้าในการอัปโหลด
เมื่อได้รับการแจ้งเตือนข้อผิดพลาด ควรแสดงการแจ้งเตือนพร้อมข้อผิดพลาดและปิดตัวเองไป
ปัญหาคือไม่มีการแสดงการแจ้งเตือนเนื่องจาก self.navigationController
เท่ากับ nil
ฉันจะนำเสนอ Alert ในกรณีนั้นได้อย่างไร?
ฉันไม่สามารถใช้กระดานเรื่องราวเพื่อสร้างอินสแตนซ์ SubmitViewController
ตามที่บางคนแนะนำ เนื่องจากไม่ได้เป็นส่วนหนึ่งของกระดานเรื่องราว
ดูตัวควบคุมที่ใช้ในการนำเสนอ SubmitViewController
:
-(void)submitBtnClicked:(id)sender {
SubmitViewController *submitViewController = [SubmitViewController new];
[self.navigationController presentViewController:submitViewController animated:YES completion:nil];
}
SubmitViewController.swift
:
@objc func submitErrorNotification(_ notification:Notification) {
self.unsubscribe()
let title:String = notification.userInfo!["title"] as! String
let message:String = notification.userInfo!["message"] as! String
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
if (self.navigationController == nil) {
NSLog("Error: navigation controller is nil");// THIS error occurs
}
self.navigationController?.present(alertController, animated: false, completion: nil)
self.dismiss(animated: false, completion: nil)
}
SubmitViewController
ของคุณและยกเลิกสิ่งนั้นในตัวจัดการการดำเนินการ - person Paulw11   schedule 02.10.2018