1
UITableViewCell
안에 UIPickerView
을 만들려고하는데 제대로 작동합니다. UIProgressView
에 대한 태그를 indexPath.row
으로 설정했습니다. 현재 내가 connection:didReceiveData:
메소드를 호출 NSURLConnection
때 NSURLConnection
문제, 마지막 행만 업데이트됩니다.
을 사용하여 파일을 다운로드 할 때 내가이 UIProgressView
을 사용하고 3 행 을 가지고, 내가 왜 마지막 행 만 확실하지 오전의 indexPath.row
일치하여 진행 상황을 업데이트하려고하지만
나를 아래와 같이 사용자 정의 클래스를 만들 수
- (void)download:(NSString*)rowId
{
NSURL *url;
if ([rowId intValue] == 0){
url = [NSURL URLWithString:@"http://192.168.0.29/iphone/video/video_10.mov"];
}
else if ([rowId intValue] == 1){
url = [NSURL URLWithString:@"http://192.168.0.29/iphone/video/video_10.mov"];
}
else if ([rowId intValue] == 2){
url = [NSURL URLWithString:@"http://192.168.0.29/iphone/video/video_10.mov"];
}
NSURLRequest *theRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:10.0];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
connection = nil;
}
- (void)connection:(NSURLConnection *)theConnection didReceiveData:(NSData *)recievedData {
if (data==nil) {
data = [[NSMutableData alloc] initWithCapacity:2048];
}
[data appendData:recievedData];
NSNumber *resourceLength = [NSNumber numberWithUnsignedInteger:[data length]];
float progress = [resourceLength floatValue]/[self.filesize floatValue];
NSLog(@"%d inside ",myId);
UIProgressView* downPreView = (UIProgressView*)[self.view viewWithTag:myId];
downPreView.progress = progress;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath
//-------------------------------------------------------------------------------
{
static NSString *CellIdentifier = @"DownloadingCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
self.progressView = [[[UIProgressView alloc]initWithFrame:CGRectMake(80,70,170,15)]autorelease];
[self.progressView setProgressViewStyle:UIProgressViewStyleBar];
self.progressView.tag = indexPath.row;
self.progressView.progress = 0.0f;
myId = indexPath.row;
NSString *aid = [NSString stringWithFormat:@"%d",myId];
NSLog(@"%@",aid);
[cell.contentView addSubview:self.progressView];
[self performSelectorOnMainThread:@selector(download:) withObject:aid waitUntilDone:NO];
if (indexPath.row == 0)
{
cell.textLabel.text = @"Beautiful Dreamer";
cell.detailTextLabel.text = @"David Lehman";
cell.imageView.image = [UIImage imageNamed:@"download_poem_icon.png"];
}
else if (indexPath.row == 1)
{
cell.textLabel.text = @"Friends a Friendship";
cell.detailTextLabel.text = @"Denise Levertov";
cell.imageView.image = [UIImage imageNamed:@"download_poem_icon.png"];
}
else {
cell.textLabel.text = @"Love and Friendship";
cell.detailTextLabel.text = @"Dorianne Laux";
cell.imageView.image = [UIImage imageNamed:@"download_poem_icon.png"];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
제가 생각하기에 문제는 다음과 같습니다. [self.view viewwithTag :] 명령어를 작성했습니다. –
그러나 [cell.contentView viewWithTag :]에 의해 셀에 연결된 progressbar 객체를 가져와야합니다. 또한 유 역시 세포에 접근해야합니다. –
@ Simha.hb : 답장을 보내 주셔서 감사합니다. 실제로 myId 값을 인쇄 할 때 항상 2로 표시됩니다 (마지막 행). 왜 2가 항상 표시됩니까? 실제로 처음 0,1, 2가되어야합니다. .pls 알려주세요 – user198725878