截图:
我遇到了很多这些崩溃,但问题是我只是指向我的appDelegate第一行。我不知道在哪里寻找这个问题。我可以从以下崩溃报告开始调查哪些想法?
Crashed: com.apple.main-thread
0 UIKit 0x18d005640 __56-
[UIPresentationController runTransitionForCurrentState]_block_invoke + 460
1 UIKit 0x18cf27aa8 _runAfterCACommitDeferredBlocks + 292
2 UIKit 0x18cf1ae5c _cleanUpAfterCAFlushAndRunDeferredBlocks + 288
3 UIKit 0x18ccac464 _afterCACommitHandler + 132
4 CoreFoundation 0x1836a6cdc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
5 CoreFoundation 0x1836a4694 __CFRunLoopDoObservers + 412
6 CoreFoundation 0x1836a4c50 __CFRunLoopRun + 1292
7 CoreFoundation 0x1835c4c58 CFRunLoopRunSpecific + 436
8 GraphicsServices 0x185470f84 GSEventRunModal + 100
9 UIKit 0x18cd1d5c4 UIApplicationMain + 236
10 AppName 0x100ae3ca4 main (AppDelegate.swift:23)
11 libdyld.dylib 0x1830e456c start + 4
更新
基于以下内容:
App crashing on runTransitionForCurrentState but no clue as to why
我正在寻找可能的原因,我想知道以下代码。
在进行同步过程时,我有以下功能用于显示带有活动指示符的视图。
public func displayActivityAlertWithCompletion(_ title: String, ViewController: UIViewController, completionHandler: @escaping ()->())
{
let pending = UIAlertController(title: "\n\n\n"+title, message: nil, preferredStyle: .alert)
//create an activity indicator
let indicator = UIActivityIndicatorView(frame: pending.view.bounds)
indicator.autoresizingMask = [.flexibleWidth, .flexibleHeight]
indicator.color = UIColor(rgba: Palette.loadingColour)
//add the activity indicator as a subview of the alert controller's view
pending.view.addSubview(indicator)
indicator.isUserInteractionEnabled = false
// required otherwise if there buttons in the UIAlertController you will not be able to press them
indicator.startAnimating()
ViewController.present(pending, animated: true, completion: completionHandler)
}
然后我就像这样使用这个函数:
displayActivityAlertWithCompletion("Pushing Data", ViewController: self){_ in
Helper_class.doSync(_cleanSync: false){
//sync is complete
Prefs.is_Syncing = false
DispatchQueue.main.async {
//dismiss my view with activity alert
self.dismiss(animated: true){
//dismiss my viewcontroller
Toast(text: "Upload sync completed").show()
self.dismiss(animated: true, completion: nil)
}
}
}
}
这会成为UIKit问题的潜在原因吗?
答案 0 :(得分:2)
按照以下步骤操作即可: 1.打开导航器; 2.切换到BreakPoint Navigator; 3.单击左下角的“+”按钮; 4.弹出时,单击“Exception BreakPoint”。
然后再次运行你的项目,它将在确切的位置中断。
答案 1 :(得分:1)
以下是我的建议:
UIViewController
函数上 - viewDidLoad
,viewWillAppear
,viewWillDisappear
等等。 根据您的代码,您将解除相同的viewController两次。将待定作为全局变量。并将其视为:
pending.dismiss(animated: true, completion: nil)
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(0.1)) {
self.dismiss(animated: true, completion: nil) // This will be called after above time gap.
}
答案 2 :(得分:0)
我在某些迁移过程中遇到了UIPresentationController
构造函数崩溃的问题。
对我来说,通过将presenting
中的source
更改为UIViewControllerTransitioningDelegate
来解决问题。
像:
public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
return PresentationController(presentedViewController: presented, presenting: source)
}
虽然它一直都是可重复的,但也许不是同一个问题..
答案 3 :(得分:0)
我遇到了相同的崩溃。我通过这种情况重现了这次崩溃。这里有一个viewController。当我使用此viewController呈现另一个viewController且动画关闭该viewController时,发生崩溃。我认为您可以添加一些条件来避免这种情况,例如判断是否viewContoller.isBeingDismissed
。如果isBeingDismissed
为true,请使用其他viewController进行当前操作。