使用UIViewController+Transitions时,UIImage Animation会禁用按钮



我有一个项目让我头疼,我想这是因为我需要通过实践来学习,因此我错过了iOS中的一些基本内容,所以不要对我大喊大叫!:-)。

我有一个iOS iPad故事板,由大约33-35个ViewControllers组成。这个概念是"世界",你可以一个视图一个视图地往下看,直到你碰到一个表面,我有一个UIImage,它是动画(25png,1.7f持续时间)。由于presentModalView只是覆盖旧视图,而不是在其他视图从底部进入时将其向上推,因此我添加了UIViewController+Transitions(http://srooltheknife.blogspot.no/2012/03/custom-transition-animation-for-modal.html)也动画删除旧的观点女巫的作品完美。。但是,当我使用这个额外的库时,每当我在UIImageView中使用动画时,所有触摸事件似乎都被禁用了。我在视图、按钮和视图上都尝试过enableUserInteraction=YES,但没有帮助。

有什么想法吗?

这是有动画的viewController:

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSLog(@"Main world view loaded....");
    NSLog(@"Bounds = %@", NSStringFromCGRect(self.view.bounds));
    //self.view.bounds = self.view.frame;
    NSLog(@"Bounds are now = %@", NSStringFromCGRect(self.view.bounds));
    self.view.clipsToBounds = YES;
    self.navigationController.navigationBarHidden = YES;
    self.view.userInteractionEnabled = YES;
    NSLog(@"User interaction is enabled?= %i", self.view.userInteractionEnabled);
    // Do any additional setup after loading the view, typically from a nib.
    NSMutableArray *images = [[NSMutableArray alloc] init];
    for (int i=1; i<=24; i++) {
        [images addObject:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"Untitled-%d", i] ofType:@"png"]]];
    }
    world.animationImages = images;
    world.animationDuration = 1.7;
    [world startAnimating];

    NSLog(@"Preparing audio");
    NSURL *audioURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"mainWorldSound" ofType:@"wav"]];
    NSError *audioError;
    player = [[AVAudioPlayer alloc] initWithContentsOfURL:audioURL error:&audioError];
    if(audioError){
        NSLog(@"Error in audioplayer: %@", [audioError localizedDescription]);
    } else {
        AVAudioSession *audioSession = [AVAudioSession sharedInstance];
        [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:NULL];
        player.numberOfLoops = -1;
        player.volume = 1.0;
        if([player isPlaying]){
            [player stop];
        }
        [player prepareToPlay];
        [player play];
        NSLog(@"Playing with volume: %f", player.volume);
    }

    [self.view setNeedsLayout];
    [self.view setNeedsDisplay];
}

所以在加载这个视图之前,我有5个视图控制器,它只是带有滑动事件的文本和图片。。这是加载新ViewController(上图)并在中对其进行动画处理的代码

- (IBAction)goToMainWorld:(id)sender {
    [self doVolumeFade];
    ViewController *mainWorld = [self.storyboard instantiateViewControllerWithIdentifier:@"mainWorld"];
    [self presentModalViewController:mainWorld withPushDirection:kCATransitionFromBottom];
}

为了更容易看到,我从我的故事板中添加了一张截图。。这里(我还不允许发布图片):在这里输入链接描述

我还尝试修改UIViewController+Transitions.m以使用navigationController默认

[self presentModalViewController:modalView animate:NO];

收件人:

[self.navigationController presentModalViewcontroller:modal view animate:NO];

但如果我这样做,它加载第一个动画视图控制器很好,但所有其他都只是第一个视图控制器被重新动画化,如果这有意义的话?

抱歉我英语不好!

如果我需要提供更多代码,请告诉我!:-)。。

感谢

好的。。我自己也弄清楚了,我对每个"视图"使用视图的技术似乎不是一个好主意。。

我从未见过UIScrollView,觉得它值得一试,似乎是我的解决方案。

记忆是一样的,但我现在得到了市场部想要的过渡等。

现在唯一的问题是让每个ScrollView页面的声音淡出,同时控制底部第二个UIScrollView中的声音,这似乎让我有些头疼。

谢谢当做Audun

最新更新