首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >怎么去ViewController?

怎么去ViewController?
EN

Stack Overflow用户
提问于 2016-04-02 11:41:59
回答 2查看 56关注 0票数 0

我有TableViewControllerViewController。我想在下载音频后进入ViewController。但我是在音频下载的时候去的。我使用fileExists,它检查音频是否被下载。但不起作用。在ViewController下载音频之后,我怎么进去呢?

这是我的下载代码

代码语言:javascript
复制
if (!fileExists) {

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Download audio?" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction* actionAdd = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        spinner.frame = CGRectMake(0, 0, 24, 24);
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        cell.accessoryView = spinner;
        [spinner startAnimating];

        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

NSString *stringURL = @"https://drive.google.com/uc?export=download&id=0B6zMam2kAK39R2Z5RlVWZkN3Vzg";
                NSURL  *url = [NSURL URLWithString:stringURL];
                NSData *urlData = [NSData dataWithContentsOfURL:url];
                [urlData writeToFile:filePath atomically:YES];

        });
        if (fileExists) {
        [self performSegueWithIdentifier: @"detailSegue" sender: self];
          }  

    }];
    UIAlertAction* actionCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {

    }];

    [alert addAction:actionAdd];
    [alert addAction :actionCancel];

    [self presentViewController:alert animated:YES completion:nil];
        }
        if (fileExists) {
        [self performSegueWithIdentifier: @"detailSegue" sender: self];

        }

    }
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-04-02 14:00:21

// **在检查器**中设置ViewController标识符之前,尝试使用此方法

代码语言:javascript
复制
  ViewController *vc17 = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"];

[self presentViewController:vc17 animated:YES completion:nil];
票数 0
EN

Stack Overflow用户

发布于 2016-04-02 12:08:59

您应该始终在主队列中执行与UI相关的代码,如:

代码语言:javascript
复制
 [self performSegueWithIdentifier: @"detailSegue" sender: self];

你最好用NSURLSessionDataTask从网上下载一些东西。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36372769

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档