如何在切换视图控制器时消除延迟?

时间:2014-04-09 18:14:13

标签: ios objective-c uiviewcontroller

我在两个视图控制器之间切换,但在第二个视图运行之前有1或2秒的延迟。如何更有效地实现这一点,以便在应用程序启动时加载所有内容?

这是我的代码:

我有一个按钮进行切换:

- (IBAction)soundListButton:(id)sender {
    BBRViewController * controller = [[BBRViewController alloc]
                                      initWithNibName:@"BBRViewController" bundle:nil];

    controller.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
    [self presentViewController:controller animated:YES completion:nil];
}

我在第二个视图上的viewDidLoad:

- (void)viewDidLoad {
    [super viewDidLoad];

    NSURL *buttonURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"applause_y" ofType:@"wav"]];

    AudioServicesCreateSystemSoundID((__bridge CFURLRef)buttonURL, 
                                     &SoundID);

    NSArray *array = [[NSArray alloc] initWithObjects:@"applause_y", @"applause_y", nil];
    self.listData = array;
}

0 个答案:

没有答案