I'm experiencing a crash on iOS 8.1 (device and simulator) when attempting to do a custom presention a UIViewController
with a custom UIPresentationController
subclass.
The exception raised prints the following to the console:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSSetM addObject:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x03bc9946 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x03479a97 objc_exception_throw + 44
2 CoreFoundation 0x03ae018b -[__NSSetM addObject:] + 699
3 UIKit 0x023bf389 -[UIPeripheralHost(UIKitInternal) _beginPinningInputViewsOnBehalfOfResponder:] + 50
4 UIKit 0x01f81188 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 2306
5 UIKit 0x01fb47ab __40+[UIViewController _scheduleTransition:]_block_invoke + 18
6 UIKit 0x01e7a0ce ___afterCACommitHandler_block_invoke + 15
7 UIKit 0x01e7a079 _applyBlockToCFArrayCopiedToStack + 415
8 UIKit 0x01e79e8e _afterCACommitHandler + 545
9 CoreFoundation 0x03aec9de __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
10 CoreFoundation 0x03aec920 __CFRunLoopDoObservers + 400
11 CoreFoundation 0x03ae235a __CFRunLoopRun + 1226
12 CoreFoundation 0x03ae1bcb CFRunLoopRunSpecific + 443
13 CoreFoundation 0x03ae19fb CFRunLoopRunInMode + 123
14 GraphicsServices 0x052fb24f GSEventRunModal + 192
15 GraphicsServices 0x052fb08c GSEventRun + 104
16 UIKit 0x01e508b6 UIApplicationMain + 1526
17 Spruce Dr 0x001015ad main + 141
18 libdyld.dylib 0x04e6eac9 start + 1
)
Here's where I vent the UIPresentationController
:
- (UIPresentationController *)presentationControllerForPresentedViewController:(UIViewController *)presented presentingViewController:(UIViewController *)presenting sourceViewController:(UIViewController *)source
{
return [[STKBlurredBackgroundContentPresentationController alloc] init];
}
UIPresentationController
's designated initializer must be used:Note: I'm answering my own question here in case anyone else makes the same mistake in the future. In retrospect, it's quite clear why using the designated initializer must be utilized.