我在实时应用程序中发生了这种随机崩溃。我知道如何修复它。我想知道如何找出有问题的代码,因为 crashlytics 日志没有在我的应用程序中显示任何代码。这是 crashlytics 崩溃吗?
由于它是随机崩溃,我无法调试它。
任何找出违规代码的指针将不胜感激。
Fatal Exception: NSInternalInconsistencyException
Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x196676a48 __exceptionPreprocess
1 libobjc.A.dylib 0x19639dfa4 objc_exception_throw
2 Foundation 0x196b4cf08 -[NSISEngine tryToOptimizeReturningMutuallyExclusiveConstraints]
3 Foundation 0x196957d34 -[NSISEngine _optimizeWithoutRebuilding]
4 Foundation 0x196957c4c -[NSISEngine optimize]
5 Foundation 0x1969578c0 -[NSISEngine performPendingChangeNotifications]
6 UIKitCore 0x19ab6c9e0 -[UIView(Hierarchy) layoutSubviews]
7 UIKitCore 0x19ab7f3d0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
8 QuartzCore 0x19d0e27dc -[CALayer layoutSublayers]
9 QuartzCore …Run Code Online (Sandbox Code Playgroud) 在从图库上传图像期间尝试缩放图像时,在 iPad 设备上出现以下错误。
此错误不会在模拟器上发生。当我使用相机在 iPad 设备上拍照和缩放时,也不会发生这种情况。
应用程序不会崩溃,这只是一个错误。
进行搜索并没有给出任何解决方案。
如何解决这个问题?
MyApp[766:521800] [lifecycle ] [u 65F7F957-8A07-4532-B921-0EA850CEB8E6:m (null)] [com.apple.mobileslideshow.photo-picker(1.0)] Connection to plugin interrupted while in use.
MyApp[766:521800] [lifecycle ] [u 65F7F957-8A07-4532-B921-0EA850CEB8E6:m (null)] [com.apple.mobileslideshow.photo-picker(1.0)] Connection to plugin invalidated while in use.
MyApp[766:521041] viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
MyApp[766:521041] [Generic] -[PUPhotoPickerHostViewController viewServiceDidTerminateWithError:] Error Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
Run Code Online (Sandbox Code Playgroud) 我正在尝试为里面的占位符文本设置颜色UISearchbar。现在我有以下代码。它不会在 iOS 13 上将白色设置为占位符文本。它适用于 iOS 12。似乎某些内容已损坏或 iOS 13 中的支持已被删除?
我已经搜索了很多并尝试了一些解决方法,但没有用。我还尝试为文本字段设置属性文本颜色,但这也不会改变颜色。
有没有可行的解决方案?
class CustomSearchBar: UISearchBar {
override init(frame: CGRect) {
super.init(frame: frame)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func awakeFromNib() {
super.awakeFromNib()
self.sizeToFit()
// Search text colour change
let textFieldInsideSearchBar = self.value(forKey: "searchField") as? UITextField
textFieldInsideSearchBar?.textColor = UIColor.white
// Search Placeholder text colour change
let placeHolderText = textFieldInsideSearchBar!.value(forKey: "placeholderLabel") as? UILabel
placeHolderText?.textColor = UIColor.white // doesn't work
}
}
Run Code Online (Sandbox Code Playgroud) 我在实时应用程序中发生了崩溃,但在开发过程中无法重现它。日志来自 Crashlytics。
我无法弄清楚崩溃的原因以及如何修复。
有什么帮助吗?
崩溃日志
Crashed: com.apple.main-thread
0 MyApp 0x100f5d538 closure #2 in MyViewController.buttonTapped(_:) + 4308292920 (<compiler-generated>:4308292920)
1 MyApp 0x101250a98 thunk for @escaping @callee_guaranteed (@guaranteed UIAlertAction) -> () + 4311386776 (<compiler-generated>:4311386776)
2 UIKitCore 0x19cb4aed0 -[UIAlertController _invokeHandlersForAction:] + 108
3 UIKitCore 0x19cb4b82c __103-[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:dismissCompletion:]_block_invoke.458 + 28
4 UIKitCore 0x19cdfcfe0 -[UIPresentationController transitionDidFinish:] + 952
5 UIKitCore 0x19ce0176c __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.503 + 208
6 UIKitCore 0x19cf055a8 -[_UIViewControllerTransitionContext completeTransition:] + 100
7 UIKitCore 0x19d981d90 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 588
8 UIKitCore 0x19d955c70 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 244 …Run Code Online (Sandbox Code Playgroud) 我是蒸汽的新手,我刚刚安装在 MacOS 上,我在构建它时遇到以下错误。有谁知道如何修理它?我已经搜索过,但提到的大多数解决方案都是针对 iOS 而不是 MacOS。
While building module 'Darwin' imported from /Users/imac1/ROOT/Vapor/Hello/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include/c_nio_http_parser.h:35:
In file included from <module-includes>:357:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/ncurses.h:141:
/opt/local/include/unctrl.h:60:63: error: unknown type name 'SCREEN'
NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
^
/opt/local/include/unctrl.h:60:53: error: function cannot return function type 'char *(int *, chtype)' (aka 'char *(int *, unsigned int)')
NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
^
/opt/local/include/unctrl.h:60:54: error: a parameter list without types is only allowed in a function definition
NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype); …Run Code Online (Sandbox Code Playgroud) 我在键盘上方添加了一个工具栏以显示完成按钮以关闭键盘。我已经在我的登录屏幕上添加了它。当键盘显示并且我点击保存的密码图标以选择保存的密码时,键盘会隐藏但工具栏不会隐藏。工具栏位于屏幕底部,然后在键盘再次显示时随键盘一起向上移动。看起来很糟糕。
如何修复它以便工具栏不会自行显示而仅使用键盘显示/隐藏?
override func viewDidLoad() {
super.viewDidLoad()
self.emailTextField.addDoneButton(title: "Done", target: self, selector: #selector(tapDone(sender:)))
self.passwordTextField.addDoneButton(title: "Done", target: self, selector: #selector(tapDone(sender:)))
}
@objc func tapDone(sender: Any) {
self.view.endEditing(true)
}
extension UITextField {
// Add done button above keyboard
func addDoneButton(title: String, target: Any, selector: Selector) {
let toolBar = UIToolbar(frame: CGRect(origin: .zero, size: CGSize(width: UIScreen.main.bounds.size.width, height: 44.0)))
let flexible = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
let barButton = UIBarButtonItem(title: title, style: .plain, target: target, action: selector)
barButton.setTitleTextAttributes([NSAttributedString.Key.font : UIFont.main, NSAttributedString.Key.foregroundColor : …Run Code Online (Sandbox Code Playgroud) 我有表格视图,下面是文本视图。我在键盘上方添加了一个工具栏来显示完成按钮。当我点击一行中的按钮以删除该行时,它会显示如下所示的 LayoutConstraints 问题。以下日志还显示了事件的流程。
我可以确认此问题与工具栏有关,如果我删除工具栏,则不会出现此问题。
https://github.com/hackiftekhar/IQKeyboardManager/issues/1616上讨论了类似的问题, 我从那里尝试了一些建议。
禁用文本视图的自动更正 -> 对我不起作用
使用此代码创建对我不起作用的 ToolBar
让 toolBar = UIToolbar(frame: CGRect(origin: .zero, size: CGSize(width: UIScreen.main.bounds.size.width, height: 44.0)))
任何修复?
textViewShouldBeginEditing
textViewDidBeginEditing
deleteButtonTapped
textViewDidEndEditing
textViewShouldBeginEditing
[LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix …Run Code Online (Sandbox Code Playgroud) 我遵循代码,但收到completionHandler 错误
没有更多上下文,表达类型不明确
据我了解,这是由于completionHandler 不匹配造成的。如何为completionHandler 返回错误的字符串/有意义的详细信息?
func fetch(urlString: String, completionHandler: @escaping (T?, Error?) -> Void) -> Void {
//...
guard let url = URL(string: urlString) else {
print("Failed to create URL!")
DispatchQueue.main.async {
completionHandler(nil, "Bad URL") // gives error: Type of expression is ambiguous without more context
}
return
}
}
Run Code Online (Sandbox Code Playgroud) 我面临着奇怪的情况。对于 Apple 推送通知,我无法从钥匙串访问导出 .p12 文件。我可以突出显示这两个项目并单击导出 2 个项目,但之后什么也没有发生。所有步骤都是正确的,因为我一直在这样做。钥匙串访问或我的 Mac 似乎有问题?几天前我成功地完成了另一把钥匙的操作,并且成功了,但现在无法导出旧钥匙。我认为生成证书时没有任何错误或问题,否则它应该适用于旧密钥。
在左侧窗格中选择登录。有什么建议么?
我们如何快速打印变量名?它类似于这个问题所讨论的Get a Swift Variable's Actual Name as String 我无法从上面的 QA 中弄清楚如何快速打印它以满足我的需要,如下所述
struct API {
static let apiEndPoint = "example.com/profile?"
static let apiEndPoint1 = "example.com/user?"
}
doSomething(endPoint: API.apiEndPoint)
doSomething(endPoint: API.apiEndPoint1)
func doSomething(endPoint: String) {
// print the variable name which should be apiEndPoint or endPoint1
}
Run Code Online (Sandbox Code Playgroud) swift ×8
ios ×7
ios13 ×2
macos ×2
swift5 ×2
uitoolbar ×2
crashlytics ×1
keychain ×1
p12 ×1
thunk ×1
uisearchbar ×1
uitextview ×1
vapor ×1