Archive
过程 with Xcode 7.3.1 (7D1014)
中的奇怪错误
0 swift 0x000000010d05766b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x000000010d056956 llvm::sys::RunSignalHandlers() + 70
2 swift 0x000000010d057ccf SignalHandler(int) + 287
3 libsystem_platform.dylib 0x00007fff91a3f52a _sigtramp + 26
4 libsystem_platform.dylib 0x000000010e1c5000 _sigtramp + 2088262384
5 swift 0x000000010b08fd11 swift::SILPassManager::runModulePass(swift::SILModuleTransform*) + 1025
6 swift 0x000000010b09053e swift::SILPassManager::runOneIteration() + 686
7 swift 0x000000010b09660e swift::runSILOptimizationPasses(swift::SILModule&) + 462
8 swift 0x000000010adaa579 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 13193
9 swift 0x000000010ada668d frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2781
10 swift 0x000000010ada20ac main + 1932
11 libdyld.dylib 0x00007fff8ff745ad start + 1
1. While running SILModuleTransform "Closure Specialization".
Command failed due to signal: Segmentation fault: 11
出现错误的文件是以下 tabBarController.swift
这有助于我做出以下内容:如果用户按下标签栏按钮,则滚动视图将显示在顶部 .
import UIKit
class tapBarController: UITabBarController, UITabBarControllerDelegate {
/// Determines whether the scrolling capability's enabled.
var scrollEnabled: Bool = true
private var previousIndex = 0
override func viewDidLoad() {
super.viewDidLoad()
delegate = self
}
/*
Always call "super" if you're overriding this method in your subclass.
*/
func tabBarController(tabBarController: UITabBarController, didSelectViewController viewController: UIViewController) {
guard scrollEnabled else {
return
}
guard let index = viewControllers?.indexOf(viewController) else {
return
}
if index == previousIndex {
var scrollViews = [UIScrollView]()
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), { [weak self] () in
self?.iterateThroughSubviews(self?.view) { (scrollView) in
scrollViews.append(scrollView)
}
guard let scrollView = scrollViews.first else {
return
}
dispatch_async(dispatch_get_main_queue(), {
scrollView.setContentOffset(CGPointZero, animated: true)
})
})
}
previousIndex = index
}
/*
Iterates through the view hierarchy in an attempt to locate a UIScrollView with "scrollsToTop" enabled.
Since the functionality relies on "scrollsToTop", it plugs easily into existing architectures - you can
control the behaviour by modifying "scrollsToTop" on your UIScrollViews.
*/
private func iterateThroughSubviews(parentView: UIView?, onRecognition: (UIScrollView) -> Void) {
guard let view = parentView else {
return
}
for subview in view.subviews {
if let scrollView = subview as? UIScrollView where scrollView.scrollsToTop == true {
onRecognition(scrollView)
}
iterateThroughSubviews(subview, onRecognition: onRecognition)
}
}
}
如果我评论孔文件,那么我没有错误 . 此外,我无法从代码中找出错误是什么(直到2天前工作,它已存档) .
在我的iPhone甚至在模拟器上工作完美 . 任何的想法?
1 回答
用这个代码替换它并且工作 .