cocos2d-objc v3.4.9迁移到Xcode7, iOS9后CCScrollView问题



将cocos2d-objc项目更新到Xcode7, iOS9后,我的CCScrollView实例被打破了。点击和平移手势无法识别+ xcode抛出控制台警告

警告:一个手势识别器(;目标= & lt; (action = handleTap:,Target =)>>)在storyboard/xib中设置被添加到多个视图(->;层=),这是不允许的,现在也是现在执行。从iOS 9.0开始,它将被放在第一个视图中加载到。

在修补CCScrollView并使用UIView的api使用相应的api方法操作当前gestureRecoznigers列表后,问题已修复

addgesturerecognizer:-removeGestureRecognizer:

- (void) onEnterTransitionDidFinish
{
    // Add recognizers to view
    UIView* view = [CCDirector sharedDirector].view;
    /*
    NSMutableArray* recognizers = [view.gestureRecognizers mutableCopy];
    if (!recognizers) recognizers = [NSMutableArray arrayWithCapacity:2];
    [recognizers insertObject:_panRecognizer atIndex:0];
    [recognizers insertObject:_tapRecognizer atIndex:0];
    view.gestureRecognizers = recognizers;
     */
    [view addGestureRecognizer:_panRecognizer];
    [view addGestureRecognizer:_tapRecognizer];
    [super onEnterTransitionDidFinish];
}
- (void) onExitTransitionDidStart
{
    // Remove recognizers from view
    UIView* view = [CCDirector sharedDirector].view;
    /*NSMutableArray* recognizers = [view.gestureRecognizers mutableCopy];
    [recognizers removeObject:_panRecognizer];
    [recognizers removeObject:_tapRecognizer];
    view.gestureRecognizers = recognizers;*/
    [view removeGestureRecognizer:_panRecognizer];
    [view removeGestureRecognizer:_tapRecognizer];
    [super onExitTransitionDidStart];
}

相关内容

  • 没有找到相关文章

最新更新