0

我发现了一些问题,但答案不适用于我的代码,因此我提出了自己的问题。

我的目标是从detailviewcontroller 重新加载表格视图。我点击一个单元格,转到详细信息,当我返回表格时,我希望它更新。问题是它不更新。所以我决定当detailviewcontroller上发生某些事情但它仍然没有工作时,最好回到rootviewcontroller。

我愿意接受建议和建议,请随时发表评论!!

我下载了一个视频,下载视频后我更新了 tableView。

这是我正在使用的代码:

我使用 MKNetworkKit 顺便说一句。

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];
}
4

0 回答 0