在iOS 4.2的iPad和iPad模拟器中使用MPMoviePlayerController时发生奇怪的崩溃

时间:2011-03-05 04:54:35

标签: ipad mpmovieplayercontroller

我试图在iPad上使用MPMoviePlayerController和使用iOS 4.2的iPad模拟器播放电影时遇到崩溃。我正在使用xcode 3.2.5和4.2 SDK构建。当使用iOS 3.2或iPad模拟器3.2在iPad上运行时,相同的代码工作正常,但在运行4.2的iPad或iPad模拟器4.2中,它会崩溃。崩溃是由于在可可库深处调用未知选择器的异常,有些尝试在UIButton对象上调用名为“setHitRectInsets:”的选择器。此外,在控制返回主事件循环后发生崩溃。任何人都知道可能导致这种情况的原因是什么?这是崩溃的代码(粗略地,删除了一些似乎没有任何影响的无关的东西):

NSString *fullMovieFilename = [[NSBundle mainBundle] pathForResource:@"movie" ofType:@"m4v"];
NSURL *movieURL = [NSURL fileURLWithPath:fullMovieFilename];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
moviePlayer.controlStyle = MPMovieControlStyleNone;  // crash happens regardless of the setting here
[moviePlayer.view setFrame:self.view.bounds];
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES]; // crash happens whether i use fullscreen or not
[moviePlayer play];

如果我使用Xcode 3.2.3和4.0 SDK构建,相同的代码也可以找到。崩溃堆栈跟踪如下所示:

2011-03-04 23:08:22.017 MyApp[31610:207] -[UIButton setHitRectInsets:]: unrecognized selector sent to instance 0x990bc60
2011-03-04 23:08:22.020 MyApp[31610:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIButton setHitRectInsets:]: unrecognized selector sent to instance 0x990bc60'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x0151abe9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x0166f5c2 objc_exception_throw + 47
    2   CoreFoundation                      0x0151c6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x0148c366 ___forwarding___ + 966
    4   CoreFoundation                      0x0148bf22 _CF_forwarding_prep_0 + 50
    5   MediaPlayer                         0x011b5bdb -[MPTransportControls createButtonForPart:] + 380
    6   MediaPlayer                         0x011b65d5 -[MPTransportControls _updateAdditions:removals:forPart:] + 110
    7   MediaPlayer                         0x011b4d78 -[MPTransportControls _reloadViewWithAnimation:] + 299
    8   MediaPlayer                         0x011b621a -[MPTransportControls setVisibleParts:] + 49
    9   MediaPlayer                         0x011b6e4a -[MPTransportControls initWithFrame:] + 173
    10  MediaPlayer                         0x011f9188 -[MPInlineTransportControls initWithFrame:] + 78
    11  MediaPlayer                         0x011f193a -[MPInlineVideoOverlay layoutSubviews] + 158
    12  QuartzCore                          0x00d6e451 -[CALayer layoutSublayers] + 181
    13  QuartzCore                          0x00d6e17c CALayerLayoutIfNeeded + 220
    14  QuartzCore                          0x00d6e088 -[CALayer layoutIfNeeded] + 111
    15  MediaPlayer                         0x011f130c -[MPInlineVideoOverlay setAllowsWirelessPlayback:] + 46
    16  MediaPlayer                         0x011f5b0d -[MPInlineVideoViewController _overlayView] + 526
    17  MediaPlayer                         0x011f6359 -[MPInlineVideoViewController _layoutForItemTypeAvailable] + 1350
    18  Foundation                          0x000e56c1 _nsnote_callback + 145
    19  CoreFoundation                      0x014f2f99 __CFXNotificationPost_old + 745
    20  CoreFoundation                      0x0147233a _CFXNotificationPostNotification + 186
    21  Foundation                          0x000db266 -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
    22  Foundation                          0x000e75a9 -[NSNotificationCenter postNotificationName:object:] + 56
    23  MediaPlayer                         0x01184dd6 -[MPAVItem _updateForNaturalSizeChange] + 278
    24  MediaPlayer                         0x011818e4 __-[MPAVItem blockForDirectAVControllerNotificationReferencingItem:]_block_invoke_1 + 82
    25  MediaPlayer                         0x011899ba -[MPAVController _postMPAVControllerSizeDidChangeNotificationWithItem:] + 138
    26  Foundation                          0x000e56c1 _nsnote_callback + 145
    27  CoreFoundation                      0x014f2f99 __CFXNotificationPost_old + 745
    28  CoreFoundation                      0x0147233a _CFXNotificationPostNotification + 186
    29  Foundation                          0x000db266 -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
    30  Celestial                           0x052a35b2 -[NSObject(NSObject_AVShared) postNotificationWithDescription:] + 176
    31  Celestial                           0x052ab214 -[AVController fpItemNotification:sender:] + 735
    32  Celestial                           0x052b5305 -[AVPlaybackItem fpItemNotificationInfo:] + 640
    33  Celestial                           0x052a3d5c -[AVObjectRegistry safeInvokeWithDescription:] + 211
    34  Foundation                          0x000fa9a6 __NSThreadPerformPerform + 251
    35  CoreFoundation                      0x014fc01f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    36  CoreFoundation                      0x0145a28b __CFRunLoopDoSources0 + 571
    37  CoreFoundation                      0x01459786 __CFRunLoopRun + 470
    38  CoreFoundation                      0x01459240 CFRunLoopRunSpecific + 208
    39  CoreFoundation                      0x01459161 CFRunLoopRunInMode + 97
    40  GraphicsServices                    0x01e4f268 GSEventRunModal + 217
    41  GraphicsServices                    0x01e4f32d GSEventRun + 115
    42  UIKit                               0x0038a42e UIApplicationMain + 1160
    43  MyApp                               0x0000837a main + 102
    44  MpApp                               0x00002009 start + 53
)
terminate called after throwing an instance of 'NSException'

已经和它斗争了好几天,并且已经在互联网上搜索了很多有类似问题的人,都没有运气。任何建议都将不胜感激。

1 个答案:

答案 0 :(得分:0)

最后我自己想出了这个,在我在UIButton上创建的类别中做了一件蠢事。我在类别中定义了一个名为'init'的方法,但是,不知道为什么我将它命名为,没有理由这样做。将名称更改为不同的名称,并解决问题。尽管如此,这样的事情可以产生奇怪结果的很好的例子:)