У меня есть статический вид таблицы с 7 секций, но я хочу, раздел 1, чтобы быть прототипом, так что я сделал это, чтобы настроить строку:Настройка количество ячейки в секции статического UITableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 1) {
return 1;
} else {
return [super tableView:tableView numberOfRowsInSection:section];
}
}
Но все пошли штраф до этой части:
return 1;
Программа вылетает после этой строки. Есть ли способ исправить это или обходное решение, которое также может достичь этого. Благодарю.
P.S. Ниже приведен стек вызовов:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray'
*** First throw call stack:
(
0 CoreFoundation 0x0000000105f6cf45 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001059e6deb objc_exception_throw + 48
2 CoreFoundation 0x0000000105f1b975 -[__NSArray0 objectAtIndex:] + 101
3 UIKit 0x0000000106a263e8 -[UITableViewDataSource tableView:heightForRowAtIndexPath:] + 181
4 UIKit 0x00000001066f622a -[UITableViewController tableView:heightForRowAtIndexPath:] + 63
5 UIKit 0x000000010666b5cf __66-[UISectionRowData refreshWithSection:tableView:tableViewRowData:]_block_invoke + 240
6 UIKit 0x000000010666ac5f -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 4876
7 UIKit 0x000000010666d2a7 -[UITableViewRowData _ensureSectionOffsetIsValidForSection:] + 279
8 UIKit 0x00000001066708bb -[UITableViewRowData rectForFooterInSection:heightCanBeGuessed:] + 423
9 UIKit 0x00000001066709e8 -[UITableViewRowData heightForTable] + 62
10 UIKit 0x000000010643c6a2 -[UITableView _updateContentSize] + 374
11 UIKit 0x0000000106462f19 -[UITableView _rebuildGeometry] + 40
12 UIKit 0x000000010646124e -[UITableView setLayoutMargins:] + 389
13 UIKit 0x0000000106461090 -[UITableView _setDefaultLayoutMargins:] + 134
14 UIKit 0x00000001064a2420 -[UIViewController _setContentOverlayInsets:] + 692
15 UIKit 0x00000001064a2e43 -[UIViewController _updateContentOverlayInsetsFromParentIfNecessary] + 2067
16 UIKit 0x00000001064a249d -[UIViewController _updateContentOverlayInsetsForSelfAndChildren] + 101
17 UIKit 0x00000001064ae199 -[UIViewController _updateLayoutForStatusBarAndInterfaceOrientation] + 972
18 UIKit 0x00000001064b3c0b -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 1242
19 UIKit 0x00000001063c7b45 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1613
20 UIKit 0x00000001063dc5ba -[UIScrollView _didMoveFromWindow:toWindow:] + 85
21 UIKit 0x00000001063c7856 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 862
22 UIKit 0x00000001063bce2c __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 155
23 UIKit 0x00000001063bcd2b -[UIView(Hierarchy) _postMovedFromSuperview:] + 544
24 UIKit 0x00000001063ca7e7 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1967
25 UIKit 0x000000010678b0ad -[UINavigationTransitionView transition:fromView:toView:] + 672
26 UIKit 0x00000001064f1791 -[UINavigationController _startTransition:fromViewController:toViewController:] + 3291
27 UIKit 0x00000001064f1d8d -[UINavigationController _startDeferredTransitionIfNeeded:] + 890
28 UIKit 0x00000001064f2cea -[UINavigationController __viewWillLayoutSubviews] + 57
29 UIKit 0x0000000106698c85 -[UILayoutContainerView layoutSubviews] + 248
30 UIKit 0x00000001063cde40 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 710
31 QuartzCore 0x0000000109e7b59a -[CALayer layoutSublayers] + 146
32 QuartzCore 0x0000000109e6fe70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
33 QuartzCore 0x0000000109e6fcee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
34 QuartzCore 0x0000000109e64475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
35 QuartzCore 0x0000000109e91c0a _ZN2CA11Transaction6commitEv + 486
36 UIKit 0x0000000106344216 _afterCACommitHandler + 174
37 CoreFoundation 0x0000000105e98947 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
38 CoreFoundation 0x0000000105e988b7 __CFRunLoopDoObservers + 391
39 CoreFoundation 0x0000000105e8e50b __CFRunLoopRun + 1147
40 CoreFoundation 0x0000000105e8de08 CFRunLoopRunSpecific + 488
41 GraphicsServices 0x0000000109708ad2 GSEventRunModal + 161
42 UIKit 0x000000010631930d UIApplicationMain + 171
43 SilverStoryClient 0x00000001054b325f main + 111
44 libdyld.dylib 0x000000010869092d start + 1
45 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Это сбой в' Tableview: heightForRowAtIndexPath: '. Что ты здесь делаешь? – Avi
проверить свой массив у него есть данные или нет –
@Avi Я не реализовал tableView: heightForRowAtIndexPath: –