【问题标题】:Strange crashes when using MPMoviePlayerController in iPad and iPad simulator with iOS 4.2在带有 iOS 4.2 的 iPad 和 iPad 模拟器中使用 MPMoviePlayerController 时出现奇怪的崩溃
【发布时间】:2011-03-05 04:54:34
【问题描述】:

尝试在 iPad 上使用 MPMoviePlayerController 播放电影时以及在使用 iOS 4.2 的 iPad 模拟器中播放电影时出现崩溃。我正在使用 xcode 3.2.5 和 4.2 SDK 构建。在使用 iOS 3.2 的 iPad 或 iPad 模拟器 3.2 中运行时,相同的代码可以正常工作,但在运行 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'

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

【问题讨论】:

    标签: ipad mpmovieplayercontroller


    【解决方案1】:

    我终于自己想通了,在我在 UIButton 上创建的类别中做了一件愚蠢的事情。我在类别中定义了一个名为“init”的方法,呃,不知道为什么我这样命名它,没有理由这样做。将名称更改为不同的名称,问题就解决了。不过,这样的事情如何产生奇怪的结果的很好的例子:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-17
      • 1970-01-01
      • 2013-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多