刚刚创建了一个应用,拖拽了一个TableView之后再拖拽一个TableViewCell在TableView上面,在把dataSource和Delegate连接到
ViewController之后运行一下应用,就出现了 unrecognized selector sent to instance这个错误
全过程都是在storyboard里面完成的,没有写代码。报错:
2015-11-16 11:08:48.679 iConvert[5140:465500] -[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7fe8b1657060
2015-11-16 11:08:48.684 iConvert[5140:465500] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7fe8b1657060'
*** First throw call stack:
(
0   CoreFoundation                      0x00000001101ccf65 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x000000010e1efdeb objc_exception_throw + 48
2   CoreFoundation                      0x00000001101d558d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3   CoreFoundation                      0x0000000110122f7a ___forwarding___ + 970
4   CoreFoundation                      0x0000000110122b28 _CF_forwarding_prep_0 + 120
5   UIKit                               0x000000010e9907ec -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 2773
6   UIKit                               0x000000010e996c5f -[UITableViewRowData rectForFooterInSection:heightCanBeGuessed:] + 391
7   UIKit                               0x000000010e996dac -[UITableViewRowData heightForTable] + 62
8   UIKit                               0x000000010e771a22 -[UITableView _updateContentSize] + 374
9   UIKit                               0x000000010e797e32 -[UITableView _rebuildGeometry] + 40
10  UIKit                               0x000000010e795dd0 -[UITableView didMoveToWindow] + 136
11  UIKit                               0x000000010e6feebc -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1768
12  UIKit                               0x000000010e7137d0 -[UIScrollView _didMoveFromWindow:toWindow:] + 85
13  UIKit                               0x000000010e6feb32 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 862
14  UIKit                               0x000000010e6f4106 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 155
15  UIKit                               0x000000010e6f4005 -[UIView(Hierarchy) _postMovedFromSuperview:] + 544
16  UIKit                               0x000000010e701ac3 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1967
17  UIKit                               0x000000010e6bd3a6 -[UIWindow addRootViewControllerViewIfPossible] + 803
18  UIKit                               0x000000010e6bd7bd -[UIWindow _setHidden:forced:] + 302
19  UIKit                               0x000000010e6cf020 -[UIWindow makeKeyAndVisible] + 43
20  UIKit                               0x000000010e64c93c -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
21  UIKit                               0x000000010e652e15 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1755
22  UIKit                               0x000000010e64fff0 -[UIApplication workspaceDidEndTransaction:] + 188
23  FrontBoardServices                  0x00000001114387ac -[FBSSerialQueue _performNext] + 192
24  FrontBoardServices                  0x0000000111438b1a -[FBSSerialQueue _performNextFromRunLoopSource] + 45
25  CoreFoundation                      0x00000001100f90a1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
26  CoreFoundation                      0x00000001100eefcc __CFRunLoopDoSources0 + 556
27  CoreFoundation                      0x00000001100ee483 __CFRunLoopRun + 867
28  CoreFoundation                      0x00000001100ede98 CFRunLoopRunSpecific + 488
29  UIKit                               0x000000010e64f98d -[UIApplication _run] + 402
30  UIKit                               0x000000010e654676 UIApplicationMain + 171
31  iConvert                            0x000000010dcf5bdf main + 111
32  libdyld.dylib                       0x0000000110e0192d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

解决方案 »

  1.   

    6 11:08:48.684 iConvert[5140:465500] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7fe8b1657060'这里不是说的很明白吗?说uiview没有tableView:numberOfRowsInSection:这个方法,所以说unrecognized selector你拖线拖错对象了
      

  2.   


    你好,我是按照树上说的选中了TableView,再在connection inspector里面分别把dataSource和delegate拖拽到ViewController那里,然后就有这个错误了。
      

  3.   


    还没有噢,只是对storyboard做了些拖拉拽的操作
      

  4.   


    还没有噢,只是对storyboard做了些拖拉拽的操作UITableView 在初始时会调用数据源的代理UITableViewDataSource, 以实现数据绑定。 如果你设置了tableview的代理为当前控制器,就需要控制器去实现 tableview的数据源代理方法,因为uitableviewdatasource中所有的协议方法都是@require的,是要求订阅者必须要实现的。
      

  5.   


    还没有噢,只是对storyboard做了些拖拉拽的操作UITableView 在初始时会调用数据源的代理UITableViewDataSource, 以实现数据绑定。 如果你设置了tableview的代理为当前控制器,就需要控制器去实现 tableview的数据源代理方法,因为uitableviewdatasource中所有的协议方法都是@require的,是要求订阅者必须要实现的。谢谢!!~现在懂了!