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