2015-10-26 43 views
1

错误我得到:虽然重新加载tableview断言失败正在发生?

Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-3347.44.2.2/UITableView.m:1326 
2015-10-26 11:38:49.473 huwai[1784:684487] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 0 from section 1, but there are only 1 sections before the update' 
*** First throw call stack: 
(0x2a94f0d7 0x390cec77 0x2a94efad 0x2b64fbc9 0x2e1771d7 0xe865f 0xe61db 0x2e12d9ef 0x2dfdcb1d 0x2e3f6811 0x2dfa5ad5 0x2dfa3a4f 0x2dfdaeed 0x2dfda7dd 0x2dfb09b5 0x2e2270ff 0x2dfaf3b7 0x2a91500f 0x2a914423 0x2a912aa1 0x2a85e6d1 0x2a85e4e3 0x321fa1a9 0x2e010445 0x11f44d 0x3969caaf) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
  1. 我使用第三方的tableview(即)TQMultistageTableView。

2.when发生此错误意味着,我正在删除数组中的值,并再次重新加载表视图,在特定的时间错误发生并非所有时间发生。

这是我的代码

我装箱这里第三方表视图

-(void)viewWillLayoutSubviews 
    { 

     if([[UIDevice currentDevice].model hasPrefix:@"iPad"]) 
     { 
      self.mTableView = [[TQMultistageTableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.viewsub.frame.size.height)]; 
     } 
     else if([[UIDevice currentDevice].model hasPrefix:@"iPhone"]) 
     { 
      self.mTableView =[[TQMultistageTableView alloc] initWithFrame:CGRectMake(0, 0, self.viewsub.frame.size.width,self.viewsub.frame.size.height)]; 
     } 
     self.mTableView.delegate = self; 
     self.mTableView.dataSource = self; 
     self.mTableView.clipsToBounds=YES; 
     self.mTableView.tableView.clipsToBounds=YES; 



    } 

- (NSInteger)numberOfSectionsInTableView:(TQMultistageTableView *)tableView 
{ 

    return [arrOrder count]; 
} 

- (NSInteger)mTableView:(TQMultistageTableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 

    return 1; 
} 
#pragma mark row 
- (UITableViewCell *)mTableView:(TQMultistageTableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 



    ServiceChargeCell *cell; 
    cell = [[ServiceChargeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell" forIndexPath:indexPath]; 
    NSLog(@"inside charge screen product array%@",arrOrder); 
    NSInteger order=[productid integerValue]; 
    NSMutableDictionary *dic=[flow.dicOrder objectForKey:@(order)]; 
    cell.lblname.textColor=[UIColor whiteColor]; 
    cell.lblname.text=[NSString stringWithFormat:@"%@",[dic objectForKey:@"description"]]; 
    NSLog(@"this is lable name=%@",[NSString stringWithFormat:@"%@",[dic objectForKey:@"description"]]); 
    NSLog(@"this is from label=%@",cell.lblname.text); 

    return cell; 



} 
- (UIView *)mTableView:(TQMultistageTableView *)tableView openCellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, tableView.bounds.size.width)]; 
    view.backgroundColor = [UIColor colorWithRed:187/255.0 green:206/255.0 blue:190/255.0 alpha:1];; 
    return view; 

} 

#pragma mark - Table view delegate 

- (CGFloat)mTableView:(TQMultistageTableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 


    if([[UIDevice currentDevice].model hasPrefix:@"iPhone"]) 
    { 
     return 40; 
    } 
    else 
    { 
     return 80; 
    } 
} 
- (CGFloat)mTableView:(TQMultistageTableView *)tableView heightForHeaderInSection:(NSInteger)section 
{ 

    if([[UIDevice currentDevice].model hasPrefix:@"iPhone"]) 
    { 
     return 50; 
    } 
    else 
    { 
     return 50; 
    } 
} 

在我的头视图我有按钮,该按钮的点击操作一些的数据都是拆卸和我再次在这里重新加载表视图。

-(void)btnClick:(UIButton *)click 
{ 
    if(click.selected==NO) 
    { 
     NSString *tag=[NSString stringWithFormat:@"%lu",(long)click.tag]; 
     int key=[tag intValue]; 
     NSMutableDictionary *dic=[flow.dicOrder objectForKey:@(key)]; 
     [flow removeOrder:dic]; 




    } 
    [self.mTableView.tableView reloadData]; 



} 

为什么这种错误的实现代码如下重装发生?请任何机构帮我在攻headerView时,来自这个问题

+0

我觉得你有没有更新您的数据源正确 – Mohamad

+0

@MohamadFarhand我只是重装tableview中,如何更新数据源... –

+1

reloadData绝对不应该崩溃tableView。我很确定这是第三方TableView在数据更新后进行某种删除操作。 – mbo42

回答

0

预定义的方法被放置在tqmultistage tableview中,只需要调用这个方法就足够了....

- (void)reloadData 
{ 
    self.isReusableCell = NO; 
    self.selectIndexPathIsOpen = NO; 
    self.selectIndexPath = [NSIndexPath indexPathForRow:-1 inSection:-1]; 
    self.selectOldIndexPathIsOpen = NO; 
    self.selectOldIndexPath = nil; 
    [self.tableView reloadData]; 
} 
1

我看着TQMultistageTableView,显然,它包含逻辑删除或插入部分。我不确定这个第三方的东西是怎么工作的,但是好像在你修改你的数据之后,第三方tableView会得到某种数据不匹配,并且它试图删除一个不存在的行。

+0

感谢您的回答,我认为如此,但有没有办法使用tableview的开始和结束更新。 –

+0

我假设你并不是真的希望tableView在手动更新数据时做任何插入或删除操作。 TQMultistageTableView在其视图中附加了一个轻触手势识别器,您可以执行的操作是在按下该按钮时检查是否在TQMultistageTableView中调用了“tableViewHeaderTouchUpInside”。在这种情况下,当您按下按钮时,您会希望找到一种方法来禁用此功能。 – mbo42

+0

但按钮的功能正常工作,并且当我点击它时,我在标题视图下显示一些数据。@ mbo42,任何可能的帮助?请帮帮我。 –