5

मेरे iOS एप्लिकेशन पर रीयल-टाइम परिदृश्य में errors कुछ जोड़े हैं। मैं इस विशेष त्रुटि को Core Foundation पर समझने में असमर्थ हूं जो मेरे आवेदन में एकाधिक उपयोगकर्ताओं को प्रभावित कर रहा है। प्रवाह मेरी किसी भी परियोजना फाइल में तोड़ नहीं रहा है और मुझे यकीन नहीं है कि इस दुर्घटना का कारण क्या है।उदाहरण के लिए भेजा गया अपरिचित चयनकर्ता _UIAlertControllerAlertPresentationController

क्रैशलिटिक्स लॉग संलग्न करना। किसी भी सलाह या मदद महान मदद, thanx होगा।

CoreFoundation _CF_forwarding_prep_0

घातक अपवाद: NSInvalidArgumentException - [_ UIAlertControllerAlertPresentationController adaptivePresentationController]: गैर मान्यता प्राप्त चयनकर्ता उदाहरण के लिए भेजा 0x133e29870

Fatal Exception: NSInvalidArgumentException 
0 CoreFoundation     0x18ff391b8 __exceptionPreprocess 
1 libobjc.A.dylib    0x18e97055c objc_exception_throw 
2 CoreFoundation     0x18ff40268 __methodDescriptionForSelector 
3 CoreFoundation     0x18ff3d270 ___forwarding___ 
4 CoreFoundation     0x18fe3680c _CF_forwarding_prep_0 
5 UIKit       0x19689708c -[UISearchController _searchPresentationController] 
6 UIKit       0x19648f8cc -[_UISearchControllerTransplantSearchBarAnimator animateTransition:] 
7 UIKit       0x19613d464 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke 
8 UIKit       0x19607ffdc _runAfterCACommitDeferredBlocks 
9 UIKit       0x196071d50 _cleanUpAfterCAFlushAndRunDeferredBlocks 
10 UIKit       0x195de10b4 _afterCACommitHandler 
11 CoreFoundation     0x18fee60c0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ 
12 CoreFoundation     0x18fee3cf0 __CFRunLoopDoObservers 
13 CoreFoundation     0x18fee4180 __CFRunLoopRun 
14 CoreFoundation     0x18fe122b8 CFRunLoopRunSpecific 
15 GraphicsServices    0x1918c6198 GSEventRunModal 
16 UIKit       0x195e597fc -[UIApplication _run] 
17 UIKit       0x195e54534 UIApplicationMain 
18 Levo       0x1000c1c30 main (AppDelegate.swift:22) 
19 libdispatch.dylib    0x18edf55b8 (Missing) 
func showErrorView(errorType: ErrorType, retryClickDelegate: ErrorViewRetryClickDelegate?) { 
    var message = "" 
    switch errorType { 
    case .INTERNET: 
     message = "Your internet connection does not seem to be working. Kindly ensure that you are connected to the internet and try again" 
     break 
    case .INVALID_DATA: 
     message = "Something went wrong. Please try again!" 
     break 
    case .JSON_PARSING: 
     message = "Something went wrong. Please try again!" 
     break 
    case .UNAUTHORIZED: 
     self.showInformativeAlert("Logged Out", message: "Looks like you have been logged out. Please login in again!", completion: nil) 
     self.switchStoryboard(Storyboard.SIGNIN) 
     return 
    default: 
     message = "Something went wrong. Please try again!" 
    } 

    let errorAlert = UIAlertController(title: "Error", message: message, preferredStyle: .Alert) 
    if let retryClickDelegate = retryClickDelegate { 
     errorAlert.addAction(UIAlertAction(title: "Try again", style: UIAlertActionStyle.Default, handler: { (action) in 
      retryClickDelegate.onErrorRetryClicked(errorType) 
      errorAlert.dismissViewControllerAnimated(true, completion: nil) 
     })) 
    } 
    errorAlert.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default, handler: nil)) 

    if (isTopViewController) { 
     self.presentViewController(errorAlert, animated: true, completion: nil) 
    } 
} 

func showInformativeAlert(title: String?, message: String?,completion : (() -> Void)?) { 
    let informativeAlert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert) 
    informativeAlert.addAction(UIAlertAction(title: "Got it!", style: UIAlertActionStyle.Default, handler: { (action) in 
     informativeAlert.dismissViewControllerAnimated(true, completion: nil) 
     completion?() 
    })) 
    self.presentViewController(informativeAlert, animated: true, completion: nil) 
} 

public var isTopViewController: Bool { 
    if self.navigationController != nil { 
     return self.navigationController?.visibleViewController === self 
    } else if self.tabBarController != nil { 
     return self.tabBarController?.selectedViewController == self && self.presentedViewController == nil 
    } else { 
     return self.presentedViewController == nil && self.isVisible 
    } 
} 
+0

आप अपनी कोशिश की कोड –

+0

http://stackoverflow.com/questions/36834755/cancelling-search-with-uisearchcontroller-causes-crash – Sulthan

+0

@ Anbu.Karthik की संभावित डुप्लिकेट दिखा सकते हैं - मुझे यकीन है कि नहीं कर रहा हूँ, जहां दुर्घटना हो रहा है, संभव प्रयास कोड के साथ पोस्ट संपादित किया है। मेरे पास इन UViewController एक्सटेंशन में इन त्रुटि दृश्य जोड़े गए हैं। – Muthu

उत्तर

0

मुझे लगता है कि समस्या यह है कि आप पूरा करने वाले हैंडलर का सही ढंग से उपयोग नहीं कर रहे हैं, इसलिए एक ही समय में एक चेतावनी दिखाई दे रही है और गायब हो रही है। उदाहरण के लिए, के बजाय के लिए:

informativeAlert.dismissViewControllerAnimated(true, completion: nil) 
    completion?() 

आप का उपयोग

informativeAlert.dismissViewControllerAnimated(true, completion: completion) 

इसके अलावा, isTopViewController के कार्यान्वयन आसानी से असफल हो सकता है अगर एक दृश्य नियंत्रक एनीमेशन प्रक्रिया में है चाहिए।

उदाहरण के लिए, यदि आप showErrorView दो बार फोन, isTopViewController शायद true दोनों कॉल और दो अलर्ट एक बार में दिखाई देने लगेगा, अपने ऐप्स क्रैश के लिए किया जाएगा।

संबंधित मुद्दे

 संबंधित मुद्दे