Чтобы не показывать MPMoviePlayerController
предупреждения UIAlertView
, вы можете использовать следующий подход:
добавьте следующие методы к вашему делегату приложения и обязательно вызовите 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), "v@:@");
// 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);
}
Имейте в виду, что Apple может отклонить этот код из-за того, что он ссылается на закрытый класс MPVideoViewController
и метод _videoView_playbackErrorNotification
.