我是iphone新手。我有一個小問題,那就是我有一個CustomCell類,因爲我已經聲明瞭所有我需要的元素,如下所示在基於單元格索引的tableview單元格中放置進度視圖
// CustomCell.h
這裏在這個類我設置的getter和setter方法來TitleLabel,PercentageLabel,ProgressView,downloadButton
// CustomCell.m
這裏在這個類的框架設置爲高於一切,並設置圖像的下載按鈕也在這裏
我的輸出屏幕的截屏
//在我的表視圖我有一個下載按鈕,當我們點擊下面的方法將執行
-(void)downloadButtonClicked:(id)sender
{
NSLog(@"download button clicked");
int index = [sender tag];
NSLog(@"index of the cell is %d",index);
UIButton *button = (UIButton*)sender;
UITableViewCell *cell = (UITableViewCell *)[[button superview] superview];
UILabel *titleLabel = (UILabel *)[cell viewWithTag:100];
NSLog(@"label text =%@",titleLabel.text);
UIView *senderButton = (UIView*) sender;
NSIndexPath *indexPath = [tableView indexPathForCell: (UITableViewCell*)[[senderButton superview]superview]];
NSLog(@"indexpath is %d",indexPath.row);
CustomCell *customCell = [[CustomCell alloc]init];
progressView = [[UIProgressView alloc]init];
// [customCell.contentView insertSubview:progressView atIndex:indexPath.row];
[customCell.contentView addSubview:progressView];
selectedBookTitle = titleLabel.text;
NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSMutableArray *allDownloadLinks;
biblePlayerViewController = [[BiblePlayerViewController alloc]init];
allDownloadLinks = [biblePlayerViewController allDownloadLinks];
NSLog(@"all Download Links are %@",allDownloadLinks);
biblePlayerViewController.indexOfSelectedBookTitle = [[appDelegate getBookNames]indexOfObject:selectedBookTitle];
Download* download = [Download downloadWithTitle:selectedBookTitle url:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.audiotreasure.com/%@.zip",[allDownloadLinks objectAtIndex:(biblePlayerViewController.indexOfSelectedBookTitle)]]]PathtoSave:documentsPath];
[[DownloadManager sharedDownloadManager] queueDownload: download];
}
//在的cellForRowAtIndexPath的tableview委託方法我這樣
- (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
CustomCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSLog(@"indexpath.row is %d",indexPath.row);
NSLog(@"downloadmanager is %d",[[[DownloadManager sharedDownloadManager]getDownloads]count]);
/* if (indexPath.row<[[[DownloadManager sharedDownloadManager] getDownloads]count])
{
cell.TitleLabel.text = ((Download*)[[[DownloadManager sharedDownloadManager] getDownloads] objectAtIndex:indexPath.row]).title_;
cell.ProgressView.progress = (float)(((Download*)[[[DownloadManager sharedDownloadManager] getDownloads] objectAtIndex:indexPath.row]).PercentageDownloaded_)/100.0f;
cell.PercentageLabel.text = [NSString stringWithFormat:@"%d %%",((Download*)[[[DownloadManager sharedDownloadManager] getDownloads] objectAtIndex:indexPath.row]).PercentageDownloaded_];
}
else
{
[tableView reloadData];
}*/
NSString *titleLabel = [[appDelegate getBookNames]objectAtIndex:indexPath.row];
cell.TitleLabel.text = titleLabel;
cell.downloadButton.tag = indexPath.row;
NSLog(@"tag is %d",cell.downloadButton.tag);
[cell.downloadButton addTarget:self action:@selector(downloadButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
我的問題都寫代碼是我66個細胞在截屏的tableview有一個名爲Revelation.It BOOKNAME有第66單元在我的tableview(指數當我單擊該單元格中的下載按鈕時,我必須僅在該特定單元格中顯示進度視圖(第65個單元格)。我已每1秒重新加載表格視圖,因爲在放置進度視圖之後,我們必須顯示該單元格中進度視圖的進度。那麼,我們如何在該特定單元格索引中放置進度視圖。