gpt4 book ai didi

ios - Swift/菜单( View )随机导致 "Command failed due to signal: Segmentation fault: 11"

转载 作者:行者123 更新时间:2023-11-30 13:12:06 28 4
gpt4 key购买 nike

我有一个带有 5 个 UIButtons 的 Menu.xib。我在 ViewController 中的按钮 IBAction 上调用此 View 。当我尝试运行代码时,编译器随机抛出:

Segmentation fault: 11

当我评论我的代码或其中的随机部分时,例如: menuView.locationBtn.addTarget(self, action: #selector(HomeVC.goLocation), forControlEvents: .TouchUpInside) 代码可能会工作或也许不会。随机地。我已经遇到这个错误有一段时间了,但找不到问题所在。

@IBAction func menuBtn(sender: AnyObject) {

let menuView = (NSBundle.mainBundle().loadNibNamed("Menu", owner: self, options: nil).last) as! Menu

menuView.frame = CGRectMake(0, self.view.bounds.size.height, self.view.bounds.size.width, 100)

menuView.homeBtn.addTarget(self, action: #selector(HomeVC.goHome), forControlEvents: .TouchUpInside)
menuView.bookmarkBtn.addTarget(self, action: #selector(HomeVC.goBookmark), forControlEvents: .TouchUpInside)
menuView.locationBtn.addTarget(self, action: #selector(HomeVC.goLocation), forControlEvents: .TouchUpInside)
menuView.photoBtn.addTarget(self, action: #selector(HomeVC.goPhoto), forControlEvents: .TouchUpInside)
menuView.friendsBtn.addTarget(self, action: #selector(HomeVC.goFriends), forControlEvents: .TouchUpInside)
menuView.settingsBtn.addTarget(self, action: #selector(HomeVC.goSettings), forControlEvents: .TouchUpInside)

self.view.addSubview(menuView)

UIView.animateWithDuration(0.6, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.8, options: .CurveEaseInOut, animations: { () -> Void in
var newMenuFrame = menuView.frame
newMenuFrame.origin.y = self.view.bounds.size.height - 63
menuView.frame = newMenuFrame
self.view.layoutIfNeeded()

}) { (success) -> Void in

let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(HomeVC.hideOnTap(_:)))
gestureRecognizer.numberOfTapsRequired = 1
gestureRecognizer.delegate = self
gestureRecognizer.cancelsTouchesInView = false
self.view.addGestureRecognizer(gestureRecognizer)
}
}

func goHome() {
print("home")
}


func goBookmark() {
print("bookmark")
}

func goLocation() {
print("location")
}

func goPhoto() {
print("photo")
}

func goFriends() {
print("friends")
}

func goSettings() {
print("settings")
}

func hideOnTap(recognizer: UITapGestureRecognizer) {
self.view.viewWithTag(5)?.removeFromSuperview()
}

当我取消整个代码的注释时,一切正常。我在其他项目中经常做过类似的事情,没有任何问题...非常感谢帮助...

编译器消息:

    0  swift                    0x000000010c3ea66b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x000000010c3e9956 llvm::sys::RunSignalHandlers() + 70
2 swift 0x000000010c3eaccf SignalHandler(int) + 287
3 libsystem_platform.dylib 0x00007fff932ba52a _sigtramp + 26
4 libsystem_platform.dylib 0x0000000000020000 _sigtramp + 1825987312
5 swift 0x000000010a5581a8 swift::ModuleFile::getType(llvm::Fixnum<31u, unsigned int>) + 872
6 swift 0x000000010a558f53 swift::ModuleFile::getType(llvm::Fixnum<31u, unsigned int>) + 4371
7 swift 0x000000010a558e44 swift::ModuleFile::getType(llvm::Fixnum<31u, unsigned int>) + 4100
8 swift 0x000000010a554d53 swift::ModuleFile::getDecl(llvm::Fixnum<31u, unsigned int>, llvm::Optional<swift::DeclContext*>) + 16259
9 swift 0x000000010a55793f swift::ModuleFile::maybeReadPattern() + 575
10 swift 0x000000010a557a92 swift::ModuleFile::maybeReadPattern() + 914
11 swift 0x000000010a55382e swift::ModuleFile::getDecl(llvm::Fixnum<31u, unsigned int>, llvm::Optional<swift::DeclContext*>) + 10846
12 swift 0x000000010a55baa9 swift::ModuleFile::readMembers(llvm::SmallVectorImpl<swift::Decl*>&) + 249
13 swift 0x000000010a55dfbe swift::ModuleFile::loadAllMembers(swift::Decl*, unsigned long long) + 206
14 swift 0x000000010a89d43c swift::NominalTypeDecl::getMembers(bool) const + 28
15 swift 0x000000010a83e3f7 (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 247
16 swift 0x000000010a83a266 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 230
17 swift 0x000000010a83a16b swift::Decl::walk(swift::ASTWalker&) + 27
18 swift 0x000000010a3b13ab swift::ClassHierarchyAnalysis::init() + 155
19 swift 0x000000010a3a8ef1 swift::createClassHierarchyAnalysis(swift::SILModule*) + 129
20 swift 0x000000010a42108d swift::SILPassManager::SILPassManager(swift::SILModule*, llvm::StringRef) + 317
21 swift 0x000000010a4290c6 swift::runSILDiagnosticPasses(swift::SILModule&) + 118
22 swift 0x000000010a13d457 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 12903
23 swift 0x000000010a13968d frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2781
24 swift 0x000000010a1350ac main + 1932
25 libdyld.dylib 0x00007fff918085ad start + 1
26 libdyld.dylib 0x000000000000007a start + 1853848270
Stack dump:

bla bla unreadable crap

1. While loading members for 'HomeVC' at <invalid loc>
2. While deserializing decl #173 (PATTERN_BINDING_DECL)
3. While deserializing decl #10 (VAR_DECL)

最佳答案

我通过“pod update”完全解决了这个问题。我会留下它,以防有人遇到同样的问题。

这让我想到了下一个问题。我的桥接 header 不再工作。我必须使用 CMD + ALT + SHIFT + K 清理项目(使用 ALT 清理它非常重要,通常的清理没有效果!)并再次运行 pod install。现在一切都恢复正常了。

关于ios - Swift/菜单( View )随机导致 "Command failed due to signal: Segmentation fault: 11",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38622792/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com