我发现了一些问题,但答案与我的代码无关,因此我问了一个问题。
我的目标是从detailviewcontroller重新加载表视图。我点击一个单元格,转到细节,当我回到表格时,我希望它更新。事情是它没有更新。因此我决定在detailviewcontroller上发生某些事情时返回到rootviewcontroller会更好,但它仍然无效。
我愿意接受建议和建议,随时发表评论!!
我下载视频,下载视频时更新tableView。
以下是我正在使用的代码:
我使用MKNetworkKit btw。
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *cachesDirectory = [paths objectAtIndex:0];
NSString *downloadPath = [cachesDirectory stringByAppendingPathComponent:videoName];
self.downloadOperation = [ApplicationDelegate.mainDownloader downloadVideoFrom:finalAddress
toFile:downloadPath];
[self.downloadOperation onDownloadProgressChanged:^(double progress) {
//DLog(@"%.2f", progress*100.0);
//self.downloadProgressBar.progress = progress;
}];
[self.downloadOperation onCompletion:^(MKNetworkOperation* completedRequest) {
//THIS DOES NOT WORK, dismissModalViewControllerAnimated.
[[ApplicationDelegate.window rootViewController] dismissModalViewControllerAnimated:YES];
DLog(@"COMPLETED REQUEST: %@", completedRequest);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Download completed"
message:@"The file is in your photo and video Library"
delegate:nil
cancelButtonTitle:NSLocalizedString(@"Thank you WebSurg!!", @"")
otherButtonTitles:nil];
[alert show];
// THIS IS WHAT I PREVIOUSLY TRIED.
// NSDictionary *tableSecData = ApplicationDelegate.videoLibraryController.tableSectionData;
// NSMutableArray *tempValuesDownloaded = [tableSecData objectForKey:@"Downloaded videos"];
// NSMutableArray *tempValuesUndownloaded = [tableSecData objectForKey:@"Undownloaded videos"];
// for (NSArray *videoArray in tempValuesUndownloaded) {
// if ([[videoArray objectAtIndex:0] isEqualToString:self.videoDetailTitle.text]) {
// [tempValuesUndownloaded removeObject:videoArray];
// [tempValuesDownloaded addObject:videoArray];
// }
// }
// [ApplicationDelegate.videoLibraryController.tableSectionData removeAllObjects];
// ApplicationDelegate.videoLibraryController.tableSectionData = [NSMutableDictionary dictionaryWithObjectsAndKeys:tempValuesDownloaded, @"Downloaded videos", tempValuesUndownloaded, @"Undownloaded videos", nil];
// [ApplicationDelegate.videoLibraryController.mainTableView reloadData];
}
onError:^(NSError* error) {
DLog(@"%@", error);
[[[UIAlertView alloc] initWithTitle:@"Download failed" message:@"The download failed because of a connection error please try again" delegate:nil cancelButtonTitle:NSLocalizedString(@"Dismiss", @"") otherButtonTitles:nil] show];
}];
} else {
UIAlertView *failureAlert=[[UIAlertView alloc] initWithTitle:@"Download status" message:@"Download failed, not enough free space." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil, nil];
[failureAlert show];
}