未在ios 7中的UITable单元格中显示的进度

时间:2013-11-27 09:37:36

标签: ios7

ios 7中UITableCell中未显示的进度。 此代码适用于ios 6.1.3但不适用于ios 7 ...

此代码适用于ios 6.1.3

-(void)updateFileProgress:(NSNotification *)notification {
    NSArray *indexAndProgress = [notification object];
    NSString *file = [indexAndProgress objectAtIndex:0];
    float progress = [[indexAndProgress objectAtIndex:1] floatValue];
    int index = [[Data sharedData] indexOfBookFileName:file];
    [[Data sharedData] persentDone:[NSNumber numberWithFloat:progress] inBookIndex:[NSNumber numberWithInt:index]];

if(!searching) {
     int bookIndex = index;
     int row = -1;
     if(iPad)   row = (bookIndex / (orientation ? 5:6));
     else   row = (bookIndex / (orientation ? 3:4));
     NSArray *indexPathes = [booksTable indexPathsForVisibleRows];
     UIButton *fbutton = nil;
           for(NSIndexPath *indexPath in indexPathes)
           {
             if(indexPath.row == row)
           {
             UITableViewCell *cell = [booksTable cellForRowAtIndexPath:indexPath];
                 for (UIButton *button in [cell subviews])
                   {
                    if([button isKindOfClass:[UIButton class]] && button.tag == bookIndex)
                   {
                   fbutton = button;
                   break;
                  }
               }
               break;
           }
           }
            NSLog(@"fbutton = %@", fbutton);
            if(fbutton) {
            UIProgressView *currentProgressView = (UIProgressView *)[fbutton viewWithTag:tPROGRESS_VIEW];
            if(currentProgressView)
                {
                    currentProgressView.progress = progress;
                } else {
                currentProgressView = [[[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault] autorelease];
               currentProgressView.frame = CGRectMake(5 , fbutton.frame.size.height - 10, fbutton.frame.size.width-10, 6);
               currentProgressView.tag = tPROGRESS_VIEW;
               currentProgressView.progress = progress;
               NSLog(@"add subview to button");
                  [fbutton addSubview:currentProgressView];
               }
               if(progress == 0 || progress >= 1 || progress < 0)
               {
               [currentProgressView removeFromSuperview];
               [[Data sharedData] performSelector:@selector(refreshBookList) withObject:nil afterDelay:1];
               [[Data sharedData] refreshBookList];
               }
            }
        }
}

在IOS 7中我创建了新的UITable结构,可能是[单元子视图]中的UIButton *按钮 - 不返回按钮,下一个代码按钮是KindOfClass:[UIButton class]] - 不起作用。

然后我将代码更改为:

for (UIButton *button in [[cell.subviews lastObject] subviews]) {
      if([button isKindOfClass:[UIButton class]] && button.tag == bookIndex) {
          fbutton = button;
          break;
      }
}

然后我将代码更改为:


for (UIButton *button in [[cell.subviews lastObject] subviews]) {
       if([button isKindOfClass:[UIButton class]] && button.tag == bookIndex) {
          fbutton = button;
          break;
        }
}

此代码返回UICellButton,但UIProgress不在表格单元格中显示。

BringToFront没有帮助。

帮助我。

0 个答案:

没有答案