我使用ASIHttpRequest下載我app.I文件顯示我爲每個文檔downloaded.The文件顯示在一個UITableView的progessbar的狀態,所以在每個文檔細胞單獨進度table.When用戶點擊「返回」,然後再次來到該文件表,我想顯示進度bar.But它不是下載文檔displayed.The代碼如下:堅持進度條
- (void)startDownloadingDocumentUsingIndexPath:(NSIndexPath*)indexPath
{
Document *document = [self.objects objectAtIndex:indexPath.row];
self.ip=indexPath;
if(isNetworkAvailable)
{
NSString *str = [NSString stringWithFormat:kBody_convertDocToByte,
document.docCatId,
document.docCatName,
document.docChksum,
document.docLocation,
document.docName,
document.docSize,
document.docType,
document.docUpdated,
document.docUpdatedBy,
document.documentId
];
NSMutableData *data = [NSMutableData dataWithData:[str dataUsingEncoding:NSUTF8StringEncoding]];
self.req = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:kURL]];
self.req.shouldAttemptPersistentConnection = NO;
[self.req setDownloadProgressDelegate:_progress];
self.req.delegate=APP_DEL;
self.req.timeOutSeconds=timeOut;
[self.req setDidFinishSelector:@selector(didFinishDownloadDocument:)];
[self.req setDidFailSelector:@selector(didFailDownloadDocument:)];
[self.req addRequestHeader:@"SOAPAction" value:kAction_convertDocToByte];
[self.req addRequestHeader:@"Content-Type" value:@"text/xml; charset=utf-8"];
[self.req setPostBody:data];
[self.req setRequestMethod:@"POST"];
[self.req setContentLength:[data length]];
self.req.userInfo=[NSDictionary dictionaryWithObjectsAndKeys:document,@"data",self.objCategory.categoryName,@"catname",self,@"vctr", nil];
[[APP_DEL nq] addOperation:self.req];
[[APP_DEL nq] go];
[APP_DEL nq].showAccurateProgress = YES;
}
else {
UIAlertView *av=[[UIAlertView alloc] initWithTitle:@"Message" message:@"Please connect to internet & try downloading/updating document later." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[av show];
}
}
我應該在代碼中做什麼修改,以保持進度條的狀態?
編輯: -文件表實際上,當用戶在「父」表中的「父」 table.The代碼選擇行顯示的「孩子」 table.It是是:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.nxt_obj_STMaster2ViewController=[[STMaster2ViewController alloc] initWithNibName:@"STMaster2ViewController" bundle:nil];
self.nxt_obj_STMaster2ViewController.objCategory=[self.objects objectAtIndex:indexPath.row];
self.nxt_obj_STMaster2ViewController.managedObjectContext=self.managedObjectContext;
self.nxt_obj_STMaster2ViewController.detailViewController=self.detailViewController;
self.nxt_obj_STMaster2ViewController.pre_STMasterViewController=self;
[tableView deselectRowAtIndexPath:indexPath animated:NO];
[self.navigationController pushViewController:self.nxt_obj_STMaster2ViewController animated:YES];
}
的viewDidLoad中的「孩子」文檔視圖控制器看起來是這樣的:
- (void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(button_refreshTapped:)];
self.navigationItem.rightBarButtonItem=item;
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"left-background.jpg"]];
[tempImageView setFrame:self.tableView.frame];
[self.tableView setBackgroundColor:[UIColor clearColor]];
self.tableView.backgroundView = tempImageView;
[self startLoadingData:self.detailViewController.liveData];
}
請出示您正在使用,以顯示視圖控制器,該文件表中的代碼,您可能需要維持一個參考。視圖控制器。 – lnafziger
@Inafziger: - 編輯的問題,更多的代碼 – user1550951