2010-08-06 76 views

回答

1

我很遗憾地告诉你,这是(据我所知)不可能做到。 我也处理过同样的问题,即使我花了很多时间调查问题,但找不到解决方案。

+1

我也是。我放弃了:(在我的应用程序中,我有更好的方法来通知警报/错误,但现在我必须接受这个不一致 – vodkhang 2010-08-12 17:23:49

+0

是的,试着在苹果开发者网站上提交一个“bug”或功能请求。未来版本 – samsam 2010-08-13 07:16:36

2

为了防止MPMoviePlayerController从显示0​​警报,您可以用下面的办法:

以下方法添加到您的应用程序委托,并确保调用patchMPVVC一次在启动时:

#import "/usr/include/objc/objc-runtime.h" 

- (void)_handleError:(NSNotification *)notification { 
    // do nothing, or add any custom error handling code here 
} 

- (void)patchMPVVC { 
    // add the _handleError: method to the MPVideoViewController class 
    Class class = NSClassFromString(@"MPVideoViewController"); 
    Method myMethod = class_getInstanceMethod([self class], @selector(_handleError:)); 
    class_addMethod(class, @selector(_handleError:), method_getImplementation(myMethod), "[email protected]:@"); 

    // swap method implementations: 
    SEL selector = sel_registerName("_videoView_playbackErrorNotification"); 
    Method originalMethod = class_getInstanceMethod(class, selector);  
    myMethod = class_getInstanceMethod(class, @selector(_handleError:)); 
    method_exchangeImplementations(originalMethod, myMethod); 
} 

请记住,由于该代码引用了专用MPVideoViewController类和_videoView_playbackErrorNotification方法,因此该代码可能会被苹果拒绝。

+1

+1用于使用私有API进行尝试 – vodkhang 2010-09-07 10:20:05

相关问题