简体   繁体   English

Eureka MultivaluedSection添加NSRangeException

[英]Eureka MultivaluedSection Add NSRangeException

Any kind of special setup needed to make MultivaluedSection Add functionality to work in Eureka? 为了使MultivaluedSection Add功能在Eureka中起作用需要任何特殊的设置吗?

I have copied code from Example project into mine and instead of rows being added I get an exception. 我已经将示例项目中的代码复制到我的代码中,而不是添加行,但出现异常。 Funny thing is that in Example project everything seems to work fine, that makes me thinking that I need some kind of additional setup, maybe? 有趣的是,在示例项目中,一切似乎都可以正常工作,这使我认为我需要某种其他设置,也许吗?

Exception: 例外:

'NSRangeException', reason: '-[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:usingPresentationValues:]: row (1) beyond bounds (1) for section (1). 'NSRangeException',原因:'-[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:usingPresentationValues:]:第(1)节的行(1)超出范围(1)。

uncaught exception 'NSRangeException', reason: '-[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:usingPresentationValues:]: row (1) beyond bounds (1) for section (1).'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010c9ab1cb __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010c30df41 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010ca1fb95 +[NSException raise:format:] + 197
    3   UIKit                               0x0000000109bc8d76 -[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:usingPresentationValues:] + 1861
    4   UIKit                               0x0000000109bc9b8f -[UITableView _scrollToRowAtIndexPath:atScrollPosition:animated:usingPresentationValues:] + 146
    5   UIKit                               0x0000000109bc9a11 -[UITableView scrollToRowAtIndexPath:atScrollPosition:animated:] + 123
    6   Eureka                              0x0000000107b7558c _T06Eureka18FormViewControllerC05tableC0ySo07UITableC0C_SC0fC16CellEditingStyleO6commit10Foundation9IndexPathV8forRowAttF + 2780
    7   Eureka                              0x0000000107b75ba7 _T06Eureka18FormViewControllerC05tableC0ySo07UITableC0C_SC0fC16CellEditingStyleO6commit10Foundation9IndexPathV8forRowAttFTo + 119
    8   UIKit                               0x0000000109bee33e -[UITableView _didInsertRowForTableCell:] + 122
    9   UIKit                               0x0000000109ec6bee -[UITableViewCell editControlWasClicked:] + 180
    10  UIKit                               0x0000000109a949bd -[UIApplication sendAction:to:from:forEvent:] + 83
    11  UIKit                               0x0000000109c0b183 -[UIControl sendAction:to:forEvent:] + 67
    12  UIKit                               0x0000000109c0b4a0 -[UIControl _sendActionsForEvents:withEvent:] + 450
    13  UIKit                               0x0000000109c0b614 -[UIControl _sendActionsForEvents:withEvent:] + 822
    14  UIKit                               0x0000000109c0a3cd -[UIControl touchesEnded:withEvent:] + 618
    15  UIKit                               0x000000010a071a88 _UIGestureEnvironmentSortAndSendDelayedTouches + 5560
    16  UIKit                               0x000000010a06b93e _UIGestureEnvironmentUpdate + 1483
    17  UIKit                               0x000000010a06b327 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 484
    18  UIKit                               0x000000010a06a3d3 -[UIGestureEnvironment _updateGesturesForEvent:window:] + 288
    19  UIKit                               0x0000000109b0a45c -[UIWindow sendEvent:] + 4102
    20  UIKit                               0x0000000109aaf802 -[UIApplication sendEvent:] + 352
    21  UIKit                               0x000000010a3e1a50 __dispatchPreprocessedEventFromEventQueue + 2809
    22  UIKit                               0x000000010a3e45b7 __handleEventQueueInternal + 5957
    23  CoreFoundation                      0x000000010c94e2b1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    24  CoreFoundation                      0x000000010c9edd31 __CFRunLoopDoSource0 + 81
    25  CoreFoundation                      0x000000010c932c19 __CFRunLoopDoSources0 + 185
    26  CoreFoundation                      0x000000010c9321ff __CFRunLoopRun + 1279
    27  CoreFoundation                      0x000000010c931a89 CFRunLoopRunSpecific + 409
    28  GraphicsServices                    0x0000000110c5a9c6 GSEventRunModal + 62
    29  UIKit                               0x0000000109a92d30 UIApplicationMain + 159

Solved. 解决了。

My custom ViewController was overriding override func viewWillAppear(_ animated: Bool) , but I forgot to call super.viewWillAppear() . 我的自定义ViewController覆盖了override func viewWillAppear(_ animated: Bool) ,但是我忘记了调用super.viewWillAppear()

Turns out that was critical for Eureka to work properly 事实证明,这对尤里卡的正常运作至关重要

Related to OP, I too had same error. 与OP有关,我也有同样的错误。 In my case it was caused because I was embedding the FormViewController() incorrectly inside another view controller. 就我而言,这是由于我将FormViewController()错误地嵌入另一个视图控制器内引起的。

My solution was to add it as childViewController ( see Eureka Issue 1045 ). 我的解决方案是将其添加为childViewController( 请参见Eureka第1045版 )。 In short, childViewControllers receive appearance & rotation events from parent VC ( viewWillAppear etc) What does addChildViewController actually do? 简而言之,childViewControllers 接收来自父VC的外观和旋转事件viewWillAppear等) addChildViewController实际做什么? .

My working Sample code (swift 4.2): 我的工作示例代码(Swift 4.2):

class MyViewController: UIViewController {

  var tempForm:FormViewController!

  override func viewDidLoad() {
    super.viewDidLoad()

    tempTemp = FormViewController()
    self.addChild(tempForm) 

    self.setupTempFormSections()
  }
  private func setupTempFormSections(){
     tempForm.form +++ Section(...)
  }
  ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM