有任何人看到“[StdMovieUISliderCell sliderType]:无法识别的选择器发送到实例” [英] has anyone seen "[StdMovieUISliderCell sliderType]: unrecognized selector sent to instance"

查看:161
本文介绍了有任何人看到“[StdMovieUISliderCell sliderType]:无法识别的选择器发送到实例”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用QTMovieView,有时,我得到以下日志,并跟随一个未知的选择器异常。该程序具有用于用户设置以显示和隐藏QTMovieView的控制器的选项。程序链接的SDK是10.7



[StdMovieUISliderCell sliderType]:无法识别的选择器发送到实例



感谢任何帮助

解决方案

这看起来像是在OS X Mountain Lion 10.8 :还有关于OS X 10.7的报告,请参见下面的注释)。我猜想 QTMovieView 将在下一个主要OS X版本中被弃用。最好的解决方案是移动到AV Foundation( AVPlayer 和相应的 AVPlayerLayer 类)。 Apple有一些有关使用此文件播放素材资源的文档框架



也就是说,如果您无法更新到AV Foundation或无法关闭自动布局你仍然可以通过在运行时动态添加缺少的方法到 StdMovieUISliderCell 类中来解决这个问题。请确保添加Objective C运行时头文件并尽早添加方法(例如在应用程序委托中添加 +(void)load )。对于App Store静态分析器拒绝foo的原因,也可以安全地添加一些简单的编码到类名如rot13。

  //确保我们有正确的标题。 
#import< objc / runtime.h>

//选择器应该被class_addMethod()识别。
@interface NSObject(SliderCellBugFix)

- (NSSliderType)sliderType;
- (NSInteger)numberOfTickMarks;

@end

//添加缺少方法的C实现,稍后我们将向您的StdMovieUISliderCell类添加
//。
static NSSliderType SliderType(id self,SEL _cmd)
{
return NSLinearSlider;
}

static NSInteger NumberOfTickMarks(id self,SEL _cmd)
{
return 0;
}

// rot13,只是为了更安全。
static NSString * ResolveName(NSString * aName)
{
const char * _string = [aName cStringUsingEncoding:NSASCIIStringEncoding];
NSUInteger stringLength = [aName length];
char newString [stringLength + 1];

NSUInteger x;
for(x = 0; x {
unsigned int aCharacter = _string [x];

if(0x40< aCharacter& aCharacter< 0x5B)// A - Z
newString [x] =(((字符 - 0x41)+ 0x0D)%0x1A) + 0x41;
else if(0x60< aCharacter& aCharacter< 0x7B)// a-z
newString [x] =(((aCharacter-0x61)+ 0x0D)%0x1A)+ 0x61;
else //不是字母字符
newString [x] = aCharacter;
}
newString [x] ='\0';

return [NSString stringWithCString:newString encoding:NSASCIIStringEncoding];
}

//如果两个方法都不存在,则添加它们。这应该使这个
//代码安全,即使苹果决定实施方法。
+(void)load
{
Class MovieSliderCell = NSClassFromString(ResolveName(@FgqZbivrHVFyvqrePryy));

if(!class_getInstanceMethod(MovieSliderCell,@selector(sliderType)))
{
const char * types = [[NSString stringWithFormat:@%s%s%s ,
@encode(NSSliderType),@encode(id),@encode(SEL)] UTF8String];
class_addMethod(MovieSliderCell,@selector(sliderType),
(IMP)SliderType,types);
}
if(!class_getInstanceMethod(MovieSliderCell,@selector(numberOfTickMarks)))
{
const char * types = [[NSString stringWithFormat:@%s%s%s ,
@encode(NSInteger),@encode(id),@encode(SEL)] UTF8String];
class_addMethod(MovieSliderCell,@selector(numberOfTickMarks),
(IMP)NumberOfTickMarks,types);
}
}



我在实现两种方法时做了两个假设: p>


  1. 影片视图只能有一个线性滑块,而不是圆形滑块。



  2. 后者可能是一个问题,如果你的电影有章节,但我不知道他们是如何处理,因为我不需要或使用它们。


    I am using QTMovieView and , sometimes, I get the following log and follow by an unknown selector exception. The program has options for users to set to show and hide controller of the QTMovieView. The SDK that the program is linking against is 10.7

    "[StdMovieUISliderCell sliderType]: unrecognized selector sent to instance"

    thanks for any help

    解决方案

    This looks like a bug that was introduced in OS X Mountain Lion 10.8 (Edit: there are also reports on OS X 10.7, see comments below) . I guess that QTMovieView will get deprecated in one of the next major OS X releases. The best solution is to move to AV Foundation (AVPlayer and the corresponding AVPlayerLayer class). Apple has some documentation about playing back assets using this framework.

    That said, if you can’t update to AV Foundation or you can’t turn off Auto Layout, you still can fix this issue by adding the missing methods dynamically during runtime to the StdMovieUISliderCell class. Make sure to add the Objective C runtime header file and to add the methods as early as possible (e.g. + (void)load in your application delegate). For App Store static analyzer rejection foo reasons, it’s also safe to add some simple encoding to the class name like rot13.

    // Make sure that we have the right headers.
    #import <objc/runtime.h>
    
    // The selectors should be recognized by class_addMethod().
    @interface NSObject (SliderCellBugFix)
    
    - (NSSliderType)sliderType;
    - (NSInteger)numberOfTickMarks;
    
    @end
    
    // Add C implementations of missing methods that we’ll add
    // to the StdMovieUISliderCell class later.
    static NSSliderType SliderType(id self, SEL _cmd)
    {
      return NSLinearSlider;
    }
    
    static NSInteger NumberOfTickMarks(id self, SEL _cmd)
    {
      return 0;
    }
    
    // rot13, just to be extra safe.
    static NSString *ResolveName(NSString *aName)
    {
      const char *_string = [aName cStringUsingEncoding:NSASCIIStringEncoding];
      NSUInteger stringLength = [aName length];
      char newString[stringLength+1];
    
      NSUInteger x;
      for(x = 0; x < stringLength; x++)
      {
        unsigned int aCharacter = _string[x];
    
        if( 0x40 < aCharacter && aCharacter < 0x5B ) // A - Z
          newString[x] = (((aCharacter - 0x41) + 0x0D) % 0x1A) + 0x41;
        else if( 0x60 < aCharacter && aCharacter < 0x7B ) // a-z
          newString[x] = (((aCharacter - 0x61) + 0x0D) % 0x1A) + 0x61;
        else  // Not an alpha character
          newString[x] = aCharacter;
      }
      newString[x] = '\0';
    
      return [NSString stringWithCString:newString encoding:NSASCIIStringEncoding];
    }
    
    // Add both methods if they aren’t already there. This should makes this
    // code safe, even if Apple decides to implement the methods later on.
    + (void)load
    {
      Class MovieSliderCell = NSClassFromString(ResolveName(@"FgqZbivrHVFyvqrePryy"));
    
      if (!class_getInstanceMethod(MovieSliderCell, @selector(sliderType)))
      {
        const char *types = [[NSString stringWithFormat:@"%s%s%s",
          @encode(NSSliderType), @encode(id), @encode(SEL)] UTF8String];
        class_addMethod(MovieSliderCell, @selector(sliderType),
          (IMP)SliderType, types);
      }
      if (!class_getInstanceMethod(MovieSliderCell, @selector(numberOfTickMarks)))
      {
        const char *types = [[NSString stringWithFormat: @"%s%s%s",
          @encode(NSInteger), @encode(id), @encode(SEL)] UTF8String];
        class_addMethod(MovieSliderCell, @selector(numberOfTickMarks),
          (IMP)NumberOfTickMarks, types);
      }
    }
    

    I made two assumptions while implementing both methods:

    1. A movie view can only have a linear slider, not a circular one.
    2. A movie view won’t have tick marks.

    The latter could be a problem if your movie has chapters, but I don’t know how they are handled, because I don’t need or use them.

    这篇关于有任何人看到“[StdMovieUISliderCell sliderType]:无法识别的选择器发送到实例”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆