views:

331

answers:

1

I have a iPhone/iPad app (universal binary) with a regular UIWebView that displays webpages on the Internet. When the user presses on a Youtube embed, the iPhone app performs normally -- opening up the video player, when you close it, it returns to the app. However, on the iPad it crashes with

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 ()

(I don't even see my app in the stack trace (except for the top level main.m)

In iPad Mobile Safari, on the same webpage, the video will play in-place on the webpage. Is there anything I have to do to enable that? Or did I forget to enable something?

A: 

As i understand this problem appers only on the universal binaries, that compiled under iPhone OS 3.1.3 and less. And not only youtube videos, but also for all kinds of media files loaded into the UIWebView. As a solution you may override UIWindow and add some dummy methods.

@interface MyWindow : UIWindow {
}
@end

@implementation MyWindow {
- (void)addEventMonitor:(void *)monitor {}
- (void)pendingMouseUpCount {}
}
FalconSer
how do I do that? in my view controller?
You should use object of the MyWindow class, which is described in the answer, when you call [window makeKeyAndVisible] into your appDelegate.
FalconSer
Can't edit your answer. From what you've suggested here is what I used to make it work instead.http://gist.github.com/427258However, I didn't use this in my final app. I re-created the app manually (still iphone app > upgrade to ipad) and it "just works" without this hack. so I'm not entirely sure what corrupted the old project.