2010-08-06 104 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

相關問題