- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当键盘出现时,我正在滚动到我的表格 View 底部。这会导致崩溃。我的代码:
func keyboardWillShow(notification: NSNotification) {
var info = notification.userInfo!
let keyboardFrame: CGRect = (info[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
self.view.layoutIfNeeded()
UIView.animateWithDuration(0.2) {
self.bottomCons.constant = keyboardFrame.size.height
self.view.layoutIfNeeded()
}
let numberOfRows = tableView.numberOfRowsInSection(0)
if numberOfRows != 0 {
do {
try tableView.scrollToRowAtIndexPath(NSIndexPath(forRow: numberOfRows-1, inSection: 0), atScrollPosition: .Bottom, animated: false) //This line is crashing
}catch {
print("error")
}
}
}
崩溃日志:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000010013e018
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [0]
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 Ribony 0x000000010013e018 specialized ChatViewController.tableView(UITableView, cellForRowAtIndexPath : NSIndexPath) -> UITableViewCell + 1904 (ChatViewController.swift:0)
1 Ribony 0x0000000100135890 @objc ChatViewController.tableView(UITableView, cellForRowAtIndexPath : NSIndexPath) -> UITableViewCell + 76 (ChatViewController.swift:0)
2 UIKit 0x000000018e315b58 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 716 (UITableView.m:10665)
3 UIKit 0x000000018e315e00 -[UITableView _createPreparedCellForRowAtIndexPath:willDisplay:] + 88 (UITableView.m:10717)
4 UIKit 0x000000018e31b4a8 -[UITableView _heightForRowAtIndexPath:] + 256 (UITableView.m:12615)
5 UIKit 0x000000018e1127c4 -[UISectionRowData heightForRow:inSection:canGuess:] + 280 (UITableViewRowData.m:288)
6 UIKit 0x000000018e4a413c -[UITableViewRowData ensureHeightsFaultedInForIndexPath:availHeight:edgeInset:scrollPosition:] + 1484 (UITableViewRowData.m:2418)
7 UIKit 0x000000018e1ef4f8 -[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:] + 1792 (UITableView.m:5544)
8 UIKit 0x000000018e1eecb0 -[UITableView scrollToRowAtIndexPath:atScrollPosition:animated:] + 52 (UITableView.m:5644)
9 Ribony 0x000000010013ed00 specialized ChatViewController.keyboardWillShow(NSNotification) -> () + 800 (ChatViewController.swift:550)
10 Ribony 0x0000000100136e98 @objc ChatViewController.keyboardWillShow(NSNotification) -> () + 56 (ChatViewController.swift:0)
11 CoreFoundation 0x00000001880b6b10 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20 (CFNotificationCenter.c:650)
12 CoreFoundation 0x00000001880b6214 _CFXRegistrationPost + 400 (CFNotificationCenter.c:164)
13 CoreFoundation 0x00000001880b5f90 ___CFXNotificationPost_block_invoke + 60 (CFNotificationCenter.c:1031)
14 CoreFoundation 0x0000000188125b8c -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1504 (CFXNotificationRegistrar.m:163)
15 CoreFoundation 0x0000000187ff7e64 _CFXNotificationPost + 376 (CFNotificationCenter.c:1028)
16 Foundation 0x0000000188b2ce0c -[NSNotificationCenter postNotificationName:object:userInfo:] + 68 (NSNotification.m:482)
17 UIKit 0x000000018e9a6b40 -[UIInputWindowController postStartNotifications:withInfo:] + 400 (UIInputWindowController.m:1375)
18 UIKit 0x000000018e9a8cf0 __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke.907 + 388 (UIInputWindowController.m:1816)
19 UIKit 0x000000018e0080f0 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 636 (UIView.m:11811)
20 UIKit 0x000000018e0d952c +[UIView(UIViewAnimationWithBlocks) _animateWithDuration:delay:options:animations:start:completion:] + 128 (UIView.m:11865)
21 UIKit 0x000000018e9a876c -[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:] + 1368 (UIInputWindowController.m:1877)
22 UIKit 0x000000018e9af268 -[UIInputWindowController setInputViewSet:] + 1444 (UIInputWindowController.m:2923)
23 UIKit 0x000000018e9a7e38 -[UIInputWindowController performOperations:withAnimationStyle:] + 56 (UIInputWindowController.m:1674)
24 UIKit 0x000000018e099278 -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 1276 (UIPeripheralHost.m:4647)
25 UIKit 0x000000018dff8a78 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 80 (UIResponder.m:1107)
26 UIKit 0x000000018e056b4c -[UIResponder becomeFirstResponder] + 600 (UIResponder.m:272)
27 UIKit 0x000000018e056ebc -[UIView(Hierarchy) becomeFirstResponder] + 148 (UIView.m:9419)
28 UIKit 0x000000018e0d90b4 -[UITextField becomeFirstResponder] + 60 (UITextField.m:1396)
29 UIKit 0x000000018e180128 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 192 (UITextInteractionAssistant.m:1160)
30 UIKit 0x000000018e17f630 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 3024 (UITextInteractionAssistant.m:1770)
31 UIKit 0x000000018e59af80 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 64 (UIGestureRecognizer.m:103)
32 UIKit 0x000000018e59e688 _UIGestureRecognizerSendTargetActions + 124 (UIGestureRecognizer.m:986)
33 UIKit 0x000000018e16573c _UIGestureRecognizerSendActions + 260 (UIGestureRecognizer.m:1020)
34 UIKit 0x000000018e0040f0 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 764 (UIGestureRecognizer.m:1067)
35 UIKit 0x000000018e58e680 _UIGestureEnvironmentUpdate + 1100 (UIGestureEnvironment.m:148)
36 UIKit 0x000000018e58e1e0 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 408 (UIGestureEnvironment.m:1181)
37 UIKit 0x000000018e58d49c -[UIGestureEnvironment _updateGesturesForEvent:window:] + 268 (UIGestureEnvironment.m:1090)
38 UIKit 0x000000018e00230c -[UIWindow sendEvent:] + 2960 (UIWindow.m:2289)
39 UIKit 0x000000018dfd2da0 -[UIApplication sendEvent:] + 340 (UIApplication.m:10729)
40 UIKit 0x000000018e7bc75c __dispatchPreprocessedEventFromEventQueue + 2736 (UIEventDispatcher.m:1430)
41 UIKit 0x000000018e7b6130 __handleEventQueue + 784 (UIEventDispatcher.m:1626)
42 CoreFoundation 0x00000001880cab5c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1943)
43 CoreFoundation 0x00000001880ca4a4 __CFRunLoopDoSources0 + 524 (CFRunLoop.c:1989)
44 CoreFoundation 0x00000001880c80a4 __CFRunLoopRun + 804 (CFRunLoop.c:2821)
45 CoreFoundation 0x0000000187ff62b8 CFRunLoopRunSpecific + 444 (CFRunLoop.c:3113)
46 GraphicsServices 0x0000000189aaa198 GSEventRunModal + 180 (GSEvent.c:2245)
47 UIKit 0x000000018e03d7fc -[UIApplication _run] + 684 (UIApplication.m:2650)
48 UIKit 0x000000018e038534 UIApplicationMain + 208 (UIApplication.m:4092)
49 Ribony 0x00000001000ce070 main + 120 (AppDelegate.swift:15)
50 libdyld.dylib 0x0000000186fd95b8 start + 4
如您所见,我在 try catch block 中使用了它。它不应该崩溃。这怎么可能?
最佳答案
试试这段代码
func keyboardWillShow(notification: NSNotification) {
var info = notification.userInfo!
let keyboardFrame: CGRect = (info[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
self.view.layoutIfNeeded()
UIView.animateWithDuration(0.2) {
self.bottomCons.constant = keyboardFrame.size.height
self.view.layoutIfNeeded()
}
tableViewScrollToBottom(true)
}
func tableViewScrollToBottom(animated: Bool) {
let delay = 0.2 * Double(NSEC_PER_SEC)
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
dispatch_after(time, dispatch_get_main_queue(), {
let numberOfSections = self.tableView.numberOfSections()
let numberOfRows = self.tableView.numberOfRowsInSection(numberOfSections-1)
if numberOfRows > 0 {
let indexPath = NSIndexPath(forRow: numberOfRows-1, inSection: (numberOfSections-1))
self.tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: UITableViewScrollPosition.Bottom, animated: animated)
}
})
}
关于ios - 关于滚动到底部的崩溃太多,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42433915/
我有一段代码看起来像这样: void update_clock(uint8_t *time_array) { time_t time = *((time_t *) &time_array[0]
应用程序崩溃了 :( 请帮助我.. 在这方面失败了。我找不到错误?该应用程序可以连接到 iTunesConnect 但它会出错。 谁能根据下面的崩溃报告判断问题出在哪里? share_with_app
小二是新来的实习生,作为技术 leader,我给他安排了一个非常简单的练手任务,把前端 markdown 编辑器里上传的图片保存到服务器端,结果他真的就把图片直接保存到了服务器上,这下可把我气坏了,就
我正在创建一个函数,它将目录路径作为参数传递,或者如果它留空,则提示用户输入。 我已经设置了我的 PATH_MAX=100 和 if 语句来检查 if ((strlen(folder path) +
我已将“arial.ttf”文件(从我的/Windows/Fonts 文件夹中获取)加载到内存中,但是将其传递到 FT_New_Memory_Face 时会崩溃(在 FT_Open_Face 中的某处
我正在尝试在我的计算机上的两个控制台之间进行 rtsp 流。 在控制台 1 上,我有: ffmpeg -rtbufsize 100M -re -f dshow -s 320x240 -i video=
我正在尝试使用 scio_beast在一个项目中。我知道它还没有完成,但这并不重要。我已经设法让它工作得很好。 我现在正在尝试连接到 CloudFlare 后面的服务器,我知道我需要 SNI 才能工作
我有一个带有关联宏的下拉列表,如下所示: Sub Drop() If Range("Hidden1!A1") = "1" Then Sheets("Sheet1").Se
我对 bash 很陌生。我要做的就是运行这个nvvp -vm /usr/lib64/jvm/jre-1.8.0/bin/java无需记住最后的路径。我认为 instafix 就是这样做...... n
我在 Windows 上使用 XAMPP 已经两年左右了,它运行完美,没有崩溃没有问题。 (直到四个月前。) 大约四个月前,我们将服务器/系统升级到了更快的规范。 这是旧规范的内容 - Windows
我面临着一个非常烦人的 android 崩溃,它发生在大约 1% 的 PRODUCTION session 中,应用程序始终在后台运行。 Fatal Exception: android.app.Re
尝试使用下面的函数: public void createObjectType() { try { mCloudDB.createObjectType(ObjectTypeIn
由于我正在进行的一个项目,我在 CF11 管理员中弄乱了类路径,我设法使服务器崩溃,以至于我唯一得到的是一个漂亮的蓝屏和 500 错误.我已经检查了日志,我会把我能做的贴在帖子的底部,但我希望有人会启
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 10 个月前关闭。 Improve
我最近从 xcode 3.x 更新到 4.2,当我在 4.2 中运行应用程序时,我遇到了核心数据问题。我还更新到了 iOS 5,所以问题可能就在那里,我不太确定。 这些应用程序在 3.x 中运行良好,
我是一个相对较新的 iPhone 应用程序开发人员,所以我的知识有点粗略,所以如果这是一个微不足道的问题,请原谅我。 我有一个导航应用程序,它通过在navigationController对象上调用p
if ([MFMailComposeViewController canSendMail]) { MFMailComposeViewController *mailViewController
你能帮我吗? 我正在设置 UILocalNotification,当我尝试设置其 userInfo 字典时,它崩溃了。 fetchedObjects 包含 88 个对象。 这是代码: NSDi
为什么我的代码中突然出现 NSFastEnumeration Mutation Handler 崩溃。我很茫然为什么会突然出现这个崩溃以及如何解决它。 最佳答案 崩溃错误: **** 由于未捕获的异常
当我从表中删除行时,我的应用程序崩溃了。这是我检测到错误和堆栈跟踪的来源。谢谢! //delete row from database - (void)tableView:(UITableView *
我是一名优秀的程序员,十分优秀!