【问题标题】:iPad app crashes when Youtube player clicked in UIWebView当 Youtube 播放器在 UIWebView 中单击时,iPad 应用程序崩溃
【发布时间】:2010-05-22 03:51:17
【问题描述】:

我有一个带有常规 UIWebView 的 iPhone/iPad 应用程序(通用二进制文件),可在 Internet 上显示网页。当用户按下 Youtube 嵌入时,iPhone 应用程序正常运行——打开视频播放器,当你关闭它时,它返回到应用程序。但是,在 iPad 上它会崩溃

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIWindow addEventMonitor:]: unrecognized selector sent to instance 0x1219c0'

#0  0x30c8e0a0 in __kill ()
#1  0x30c8e096 in kill ()
#2  0x30c8e088 in raise ()
#3  0x30ca2210 in abort ()
#4  0x32944a22 in __gnu_cxx::__verbose_terminate_handler ()
#5  0x335657ca in _objc_terminate ()
#6  0x32942df4 in __cxxabiv1::__terminate ()
#7  0x32942e48 in std::terminate ()
#8  0x32942f18 in __cxa_throw ()
#9  0x335646aa in objc_exception_throw ()
#10 0x32c9517a in -[NSObject doesNotRecognizeSelector:] ()
#11 0x32c94b00 in ___forwarding___ ()
#12 0x32c316d0 in __forwarding_prep_0___ ()
#13 0x32810492 in -[MPInactivityMonitor initForWindow:inactivityDuration:delegate:] ()
#14 0x32831dfe in -[MPFullScreenVideoViewController _createInactivityMonitor] ()
#15 0x328324bc in -[MPFullScreenVideoViewController showOverlayAnimated:] ()
#16 0x32833612 in -[MPAbstractFullScreenVideoViewController setControlsOverlayVisible:animate:] ()
#17 0x3281fca4 in -[UIMoviePlayerController setControlsOverlayVisible:disableAutohide:animate:] ()
#18 0x330bb444 in -[YTMovieView _switchToVideo:] ()
#19 0x330bb028 in -[YTMovieView willShowForVideo:inList:orVideoID:] ()
#20 0x04b8d142 in dyld_stub_time ()
#21 0x04b8b82e in dyld_stub_time ()
#22 0x32c2616c in -[NSObject performSelector:withObject:withObject:] ()
#23 0x3152716c in -[UIApplication sendAction:to:from:forEvent:] ()
#24 0x3152710c in -[UIApplication sendAction:toTarget:fromSender:forEvent:] ()
#25 0x315270de in -[UIControl sendAction:to:forEvent:] ()
#26 0x31526e30 in -[UIControl(Internal) _sendActionsForEvents:withEvent:] ()
#27 0x3152747e in -[UIControl touchesEnded:withEvent:] ()
#28 0x31525e54 in -[UIWindow _sendTouchesForEvent:] ()
#29 0x3152579c in -[UIWindow sendEvent:] ()
#30 0x315213be in -[UIApplication sendEvent:] ()
#31 0x31520d2a in _UIApplicationHandleEvent ()
#32 0x30d62b32 in PurpleEventCallback ()
#33 0x32c23d9c in CFRunLoopRunSpecific ()
#34 0x32c234e0 in CFRunLoopRunInMode ()
#35 0x30d620da in GSEventRunModal ()
#36 0x30d62186 in GSEventRun ()
#37 0x314d54c8 in -[UIApplication _run] ()
#38 0x314d39f2 in UIApplicationMain ()

(我什至没有在堆栈跟踪中看到我的应用程序(除了顶级 main.m)

在 iPad Mobile Safari 中,在同一网页上,视频将在网页上就地播放。我需要做些什么来启用它吗?还是我忘记启用某些东西?

【问题讨论】:

  • 我在黑暗中拍摄,请耐心等待。您是否尝试过包含 MediaPlayer.Framework?你真的不应该这样做,但它似乎在那里打破了。还要确保 iPad 上的操作系统版本是最新的(尽管我认为他们在 iPad 的第一个生产版本之后没有发布任何更新)
  • 我尝试过使用和不使用媒体播放器框架——没有区别。我以同样的方式创建了另一个“hello world”应用程序(iphone 应用程序,升级到 ipad)并且 youtube 视频工作正常。所以我已经手动移植了代码:-P 仍然不确定是什么损坏了旧应用

标签: iphone uiwebview youtube


【解决方案1】:

据我了解,此问题仅出现在通用二进制文件上,即在 iPhone OS 3.1.3 及更低版本下编译的。不仅是 youtube 视频,还包括加载到 UIWebView 中的各种媒体文件。 作为一种解决方案,您可以覆盖 UIWindow 并添加一些虚拟方法。

@interface MyWindow : UIWindow {
}
@end

@implementation MyWindow {
- (void)addEventMonitor:(void *)monitor {}
- (void)pendingMouseUpCount {}
}

【讨论】:

  • 我该怎么做?在我的视图控制器中?
  • 当您将 [window makeKeyAndVisible] 调用到您的 appDelegate 中时,您应该使用答案中描述的 MyWindow 类的对象。
  • 无法编辑您的答案。根据您在此处的建议,我曾经使用它来代替它。 gist.github.com/427258 但是,我没有在我的最终应用程序中使用它。我手动重新创建了应用程序(仍然是 iphone 应用程序 > 升级到 ipad)并且它“正常工作”而没有这个 hack。所以我不完全确定是什么破坏了旧项目。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-12-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多