Ios 同一控制器中的两个UITableView

Ios 同一控制器中的两个UITableView,ios,uitableview,ios7,xcode5,Ios,Uitableview,Ios7,Xcode5,我认为这是一个错误 IOS 7.0,XCode 5 我的故事板中有一个表视图控制器。我有一个带有“3”个静态单元格的TableView。然后我添加了一个“视图”,并在其中添加了一个带有动态原型的TableView 当我尝试在动态表中添加超过“3”个单元格时,应用程序崩溃 2016-01-10 08:18:21.358 Know[1381:a0b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '

我认为这是一个错误

IOS 7.0,XCode 5

我的故事板中有一个表视图控制器。我有一个带有“3”个静态单元格的TableView。然后我添加了一个“视图”,并在其中添加了一个带有动态原型的TableView

当我尝试在动态表中添加超过“3”个单元格时,应用程序崩溃

2016-01-10 08:18:21.358 Know[1381:a0b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 3 beyond bounds [0 .. 2]'
*** First throw call stack:
(
    0   CoreFoundation                      0x017535e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x014d68b6 objc_exception_throw + 44
    2   CoreFoundation                      0x01707a32 -[__NSArrayI objectAtIndex:] + 210
    3   UIKit                               0x00772983 -[UITableViewDataSource tableView:heightForHeaderInSection:] + 50
    4   UIKit                               0x00504fba -[UITableViewController tableView:heightForHeaderInSection:] + 61
    5   UIKit                               0x00333920 -[UITableView _delegateWantsHeaderForSection:] + 349
    6   UIKit                               0x0049a8f7 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 133
    7   UIKit                               0x0049eb3d -[UITableViewRowData numberOfRows] + 98
    8   UIKit                               0x003274c2 -[UITableView noteNumberOfRowsChanged] + 120
    9   UIKit                               0x00326e6f -[UITableView reloadData] + 814
    10  UIKit                               0x0032a8d3 -[UITableView _reloadDataIfNeeded] + 65
    11  UIKit                               0x0032f4f4 -[UITableView layoutSubviews] + 36
    12  UIKit                               0x002b3dd7 -[UIView(CALayerDelegate) 
这是静态表的节计数

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    if (tableView == self.ismTableView) {
        return 4;
    } else {
        // Static sections
        return 3;
    }
}
即使我正在检查表名并返回正确的计数,它似乎没有接受它。

明白了

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    if (tableView == self.ismTableView) {
        return 1;
    } else {
        // Static sections
        return 3;
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows.
    if (tableView == self.ismTableView) {
        return 4;
    } else {
        // Static sections
        return 1;
    }
}

- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 0;
}
未添加
indentationlevelforrowatinexpath
,它引发了另一个异常:

2016-01-10 08:32:07.134 Know[1607:a0b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(
    0   CoreFoundation                      0x017535e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x014d68b6 objc_exception_throw + 44
    2   CoreFoundation                      0x01707a32 -[__NSArrayI objectAtIndex:] + 210
    3   UIKit                               0x00772b9e -[UITableViewDataSource tableView:indentationLevelForRowAtIndexPath:] + 127
    4   UIKit                               0x0050509a -[UITableViewController tableView:indentationLevelForRowAtIndexPath:] + 61
    5   UIKit                               0x00332035 __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 1786
    6   UIKit                               0x002aaf5f +[UIView(Animation) performWithoutAnimation:] + 82
    7   UIKit                               0x002aafa8 +[UIView(Animation) _performWithoutAnimation:] + 40
    8   UIKit                               0x00331936 -[UITableView _configureCellForDisplay:forIndexPath:] + 108
    9   UIKit                               0x00337d4d -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 442
    10  UIKit                               0x00337e03 -[UITableView _createPreparedCellForGlobalRow:] + 69
    11  UIKit                               0x0031c124 -[UITableView _updateVisibleCellsNow:] + 2378
    12  UIKit                               0x0032f5a5 -[UITableView layoutSubviews] + 213
    13  UIKit                               0x002b3dd7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
    14  libobjc.A.dylib                     0x014e881f -[NSObject 

第二个表视图正在调用tableView方法的默认实现,此默认实现使用控制器(第一个表视图)的tableView属性,该属性只有三个单元格。所以我想您必须重写所有接收indexPath的方法,并在每个方法中检查表视图?为什么不使用子视图控制器?@Wain是的,检查每个方法。如何使用子视图控制器?我应该为自定义类指定什么?