我做的代碼,以顯示電池的衰落時,點擊該司,代碼工作很好的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
如果任何線索,然後答覆感謝
到目前爲止,您已經完成了哪些工作來追蹤錯誤? – Monolo 2011-12-23 10:38:47
我曾試圖檢查沒有。的部分在表視圖和n在運行時我得到了行的計數部分,它在IOS 3.0和4.0工作良好... – bhavin 2011-12-23 14:56:08
謝謝,但現在我得到了不同的方式來做到這一點 – bhavin 2011-12-23 14:56:38