代码之家  ›  专栏  ›  技术社区  ›  choonkeat

当YouTube播放器在uiwebview中点击时,iPad应用程序崩溃。

  •  0
  • choonkeat  · 技术社区  · 14 年前

    我有一个iPhone/iPad应用程序(通用二进制),它有一个常规的uiwebview,可以在互联网上显示网页。当用户按下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中,在同一网页上,视频将在该网页上播放。我有什么要做的吗?还是我忘了启用某些功能?

    1 回复  |  直到 14 年前
        1
  •  0
  •   FalconSer    14 年前

    据我所知,这个问题只出现在iPhoneOS3.1.3及以下版本的通用二进制文件上。不仅是YouTube视频,还包括加载到uiwebview中的各种媒体文件。 作为解决方案,您可以重写uiwindow并添加一些虚拟方法。

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