2011-12-23 45 views
-1

我做的代碼,以顯示電池的衰落時,點擊該司,代碼工作很好的IOS 3.0和4.0組 代碼看起來像通過單擊表視圖在iOS 5.0上運行時崩潰應用程序;

- (NSArray*)indexPathsInSection:(NSInteger)section { 
     NSMutableArray *paths = [NSMutableArray array]; 
     NSInteger row; 

    for (row = 0; row < [self numberOfRowsInSection:section]; row++) 
      { 
    [paths addObject:[NSIndexPath indexPathForRow:row inSection:section]]; 
     } 

    return [NSArray arrayWithArray:paths]; 
} 
- (void)toggle:(BOOL*)isExpanded section:(NSInteger)section { 
     *isExpanded = !*isExpanded; 


    [Table beginUpdates]; 
    if (!*isExpanded) 
     { 
     NSArray *paths = [self indexPathsInSection:section]; 
      [Table deleteRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationFade]; 

     } 
    else { 
      NSArray *paths = [self indexPathsInSection:section]; 
      [Table insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationRight]; 
      } 


    [Table endUpdates]; 
    [Table reloadData]; 
    } 
- (NSInteger)numberOfRowsInSection:(NSInteger)section { 

if(kMAX_SECTION_ROWS[section] == 0) 
{ 
    return 1; 
} 
else 
{ 
    return kMAX_SECTION_ROWS[section]; 
} 
//return 0; 
} 

    - (void)toggleSection:(id)sender { 
    NSLog(@"button %d is clicked.",[sender tag]); 
int i = [sender tag]; 
if(!isSectionExpanded[i]){ 
    NSLog(@"expanded"); 
    hString[i].arrowImage.image = [UIImage imageNamed:@"downarrow.png"]; 
} 
else { 
    NSLog(@"not expanded"); 
    hString[i].arrowImage.image = [UIImage imageNamed:@"arrowgrean.png"]; 
} 

[self toggle:&isSectionExpanded[i] section:i]; 
} 

當我運行的代碼IOS 5它讓我錯誤

 Assertion failure in -[_UITableViewUpdateSupport _computeRowUpdates],/SourceCache/UIKit_Sim/UIKit-1912.3/UITableViewSupport.m:386    

如果任何線索,然後答覆感謝

+0

到目前爲止,您已經完成了哪些工作來追蹤錯誤? – Monolo 2011-12-23 10:38:47

+0

我曾試圖檢查沒有。的部分在表視圖和n在運行時我得到了行的計數部分,它在IOS 3.0和4.0工作良好... – bhavin 2011-12-23 14:56:08

+0

謝謝,但現在我得到了不同的方式來做到這一點 – bhavin 2011-12-23 14:56:38

回答

0

喜的朋友我有,我發現這對每部iOS作品爲同一來源,所以任何一個人想它只是去博客: http://soulwithmobiletechnology.blogspot.com/2011/06/how-does-uitableviewcell-reorder.html

我認爲這可以節省您的大量時間 感謝

+0

我也面臨同樣的問題,但沒有得到任何幫助,從你建議的鏈接。你可以發佈一些其他鏈接來解決這個問題。 – Purva 2013-04-22 07:39:10

+0

雅我也無法解決這個問題,所以我使用了上述鏈接的代碼,並且能夠在我最後一個項目中完成。你也可以從那裏使用。 – bhavin 2013-04-22 08:39:29

0

也許iOS5的是更挑剔,你說的事情。當你寫

if(kMAX_SECTION_ROWS[section] == 0) 

你應該真的返回0而不是1(否則返回一個節標題在其他地方)。

+0

謝謝你您的支持,但我有另一種方式使它發生 – bhavin 2011-12-23 14:53:54

相關問題