My app (iOS 8 only) has been rejected due to a crash when IAP are attempted. I've tried pretty much every incantation of the purchase process in an AdHoc build but cannot reproduce a crash. Looking at the crash log that the review team attached, I am seeing a very weird stack trace in the last exception backtrace. The crash looks to be involving UIPopoverController, however my app, though universal, does not explicitly or implicitly display popovers anywhere. Does anyone have any idea what might trigger the activity that is causing this crash? What might cause my app to display popovers when the review team is looking at it only?
Last Exception Backtrace:
0 CoreFoundation 0x186d52084 __exceptionPreprocess + 132
1 libobjc.A.dylib 0x1977a40e4 objc_exception_throw + 60
2 UIKit 0x18bc0aee0 -[UIPopoverPresentationController presentationTransitionWillBegin] + 2464
3 UIKit 0x18b7d27d8 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 1324
4 UIKit 0x18b7d1310 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 212
5 UIKit 0x18b557388 _applyBlockToCFArrayCopiedToStack + 356
6 UIKit 0x18b4c8e4c _afterCACommitHandler + 532
7 CoreFoundation 0x186d0a388 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
8 CoreFoundation 0x186d07314 __CFRunLoopDoObservers + 360
9 CoreFoundation 0x186d076f4 __CFRunLoopRun + 836
10 CoreFoundation 0x186c35664 CFRunLoopRunSpecific + 396
11 GraphicsServices 0x18fd435a4 GSEventRunModal + 168
12 UIKit 0x18b53a984 UIApplicationMain + 1488
Not sure if it's the same cause as the original question, but I have the exact same error and the issue was using a UIAlertController with an ActionSheet style, presenting it worked fine on iPhone but iPad requires a sourceview to be set - https://stackoverflow.com/a/24233937/285694
This is a just similar situation. I had a crash bug on [UIPopoverPresentationController presentationTransitionWillBegin] on iOS 9+, and turns out that the crash occurred when sourceView was nil.
Example (in Objective-C):
UIViewController *vc = <#instance#>.
vc.modalPresentationStyle = UIModalPresentationPopover;
vc.popoverPresentationController.delegate = self;
vc.popoverPresentationController.sourceView = sourceView; // <--- this MUST NOT be nil.
vc.popoverPresentationController.sourceRect = sourceView.bounds;
[self presentViewController:vc animated:YES completion:nil];
It most probable the ActionSheet crash in iPad.
You should have a if condition like:
if let popoverController = alertVC.popoverPresentationController {
popoverController.sourceView = self.view
popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
popoverController.permittedArrowDirections = []
}
First you should check UIPopoverPresentationController available or not.
NSArray *Items = [NSArray arrayWithObjects:emailBody,anImage, nil];
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:Items applicationActivities:nil];
if ([UIPopoverPresentationController class] != nil) {
UIPopoverPresentationController *popover = activityController.popoverPresentationController;
if (popover)
{
popover.sourceView = sender;
//popover.sourceRect = sender.bounds;
popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
}
}
[self presentViewController:activityController animated:YES completion:NULL];
Related
I have a problem with objective-c code that handles openning camera to take a picture the code is injected as native code inside codename one
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
NSArray *mediaTypes = [[NSArray alloc]initWithObjects:(NSString *)kUTTypeImage, nil];
imagePicker.mediaTypes = mediaTypes;
imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:imagePicker animated:YES completion:nil];
}else{
[self showAlert:#"No Camera Privilege On This Device"];
}
the problem is when the above code is executed on iOS-11 ,I get null pointer exception from codenameone without asking for camera permission unlike iOS-12
the code works perfectly
the permission are added in the codenamesettings
codename1.arg.ios.NSPhotoLibraryAddUsageDescription=The App uses the Photo Library to save Images downloaded from News
codename1.arg.ios.NSCameraUsageDescription=The App uses the Camera for Video Chat support
codename1.arg.ios.NSPhotoLibraryUsageDescription=The App uses the Photo Library to save Images downloaded from News
is there anything that can be done to handle the issue on iOS11
--exception stack-trace from simulator using Xcode9.2
2018-10-04 18:47:50.830359+0300 TestApplication[7630:35311] *** Assertion failure in -[UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.33.6/UIApplication.m:1709
2018-10-04 18:47:50.853277+0300 TestApplication[7630:35311] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'accessing _cachedSystemAnimationFence requires the main thread'
*** First throw call stack:
(
0 CoreFoundation 0x000000010da7312b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010d107f41 objc_exception_throw + 48
2 CoreFoundation 0x000000010da782f2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000109d38d69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x0000000107ac692d -[UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:] + 359
5 UIKit 0x0000000107b51ac9 +[UIWindow _synchronizeDrawingWithPreCommitHandler:] + 57
6 UIKit 0x00000001082cfb7b -[UIInputViewAnimationStyle launchAnimation:afterStarted:completion:forHost:fromCurrentPosition:] + 99
7 UIKit 0x000000010872be9a -[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:] + 1697
8 UIKit 0x0000000108734c8f __43-[UIInputWindowController setInputViewSet:]_block_invoke.1493 + 97
9 UIKit 0x0000000108724208 -[UIInputWindowController performOperations:withTemplateNotificationInfo:] + 46
10 UIKit 0x000000010873481b -[UIInputWindowController setInputViewSet:] + 1336
11 UIKit 0x000000010872b450 -[UIInputWindowController performOperations:withAnimationStyle:] + 50
12 UIKit 0x00000001082c8164 -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 1669
13 UIKit 0x00000001082bff4b -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 2163
14 UIKit 0x00000001082c9480 -[UIPeripheralHost(UIKitInternal) _preserveInputViewsWithId:animated:reset:] + 498
15 UIKit 0x0000000107c89130 -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1233
16 UIKit 0x0000000107c8ae94 -[UIViewController _presentViewController:withAnimationController:completion:] + 4621
17 UIKit 0x0000000107c8d9a9 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 99
18 UIKit 0x0000000107c8e079 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 532
19 UIKit 0x0000000107c8d908 -[UIViewController _presentViewController:animated:completion:] + 181
20 UIKit 0x0000000107c8dc67 -[UIViewController presentViewController:animated:completion:] + 159
appreciate the help
Regards,
thanks for all of your help , the problem as stated was only on iOS11 , and the reason for that if I present any viewcontroller with animated:Yes and I changed how to call the view controller by adding the following code
dispatch_queue_t _serialQueue = dispatch_queue_create("x.y.z", DISPATCH_QUEUE_CONCURRENT);
dispatch_sync(_serialQueue, ^{
self.filePath=param;
[self showForm];
});
and the showForm : just take a copy of the old viewcontroller and present the new one like this [condition was used to wait for the camera to finish picking and saving the file to gallery] :
-(void)showForm{
condition = [[NSCondition alloc] init];
self.parentViewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
[self.parentViewController.view setUserInteractionEnabled:NO];
destinationViewController = [[ViewController alloc] initWithValues:self.filePath andCondition:condition andChoice:#"Camera"];
[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:destinationViewController animated:NO completion:nil];
[condition lock];
[condition wait];
self.filePath = [(ViewController*)destinationViewController getImagePath];
[self.parentViewController.view setUserInteractionEnabled:YES];
[condition unlock];
}
I hope that would help any one who needs it
Regards,
The setContentViewController method in UIPopoverController seems to be causing an app crash in iOS 8. Just wondering if anybody else also faced this issue in iOS 8. This works without any issue in iOS 7.
The error pointed in the exception seems to be misleading as it states that the setContentViewController should be called after presenting the popover
- (void)buttonPressed {
UIViewController *tableViewController = [UIViewController new];
if(_popover == nil){
_popover = [[UIPopoverController alloc] initWithContentViewController:tableViewController];
[_popover presentPopoverFromRect:CGRectMake(self.textField.frame.size.width / 2, self.textField.frame.size.height / 1, 1, 1) inView:self.textField permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
}else{
[_popover setContentViewController:tableViewController];
}
}
Here is Stack trace from the crash,
2014-09-11 16:48:39.904 iOS 8 Rotation[3969:67869] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController setContentViewController:animated:] can only be called after the popover has been presented.'
*** First throw call stack:
(
0 CoreFoundation 0x01c79df6 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x01903a97 objc_exception_throw + 44
2 CoreFoundation 0x01c79d1d +[NSException raise:format:] + 141
3 UIKit 0x00b1946f -[UIPopoverPresentationController _setContentViewController:animated:] + 89
4 UIKit 0x009bb1b4 -[UIPopoverController setContentViewController:animated:] + 155
5 UIKit 0x009bb114 -[UIPopoverController setContentViewController:] + 48
6 iOS 8 Rotation 0x00046ca5 -[MianViewController buttonPressed] + 933
7 libobjc.A.dylib 0x019197cd -[NSObject performSelector:withObject:withObject:] + 84
8 UIKit 0x002ef79d -[UIApplication sendAction:to:from:forEvent:] + 99
9 UIKit 0x002ef72f -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
10 UIKit 0x00422a16 -[UIControl sendAction:to:forEvent:] + 69
11 UIKit 0x00422e33 -[UIControl _sendActionsForEvents:withEvent:] + 598
12 UIKit 0x0042209d -[UIControl touchesEnded:withEvent:] + 660
13 UIKit 0x0033faba -[UIWindow _sendTouchesForEvent:] + 874
14 UIKit 0x00340595 -[UIWindow sendEvent:] + 791
15 UIKit 0x00305aa9 -[UIApplication sendEvent:] + 242
16 UIKit 0x003158de _UIApplicationHandleEventFromQueueEvent + 20690
17 UIKit 0x002ea079 _UIApplicationHandleEventQueue + 2206
18 CoreFoundation 0x01b9d7bf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
19 CoreFoundation 0x01b932cd __CFRunLoopDoSources0 + 253
20 CoreFoundation 0x01b92828 __CFRunLoopRun + 952
21 CoreFoundation 0x01b921ab CFRunLoopRunSpecific + 443
22 CoreFoundation 0x01b91fdb CFRunLoopRunInMode + 123
23 GraphicsServices 0x040cc24f GSEventRunModal + 192
24 GraphicsServices 0x040cc08c GSEventRun + 104
25 UIKit 0x002ede16 UIApplicationMain + 1526
26 iOS 8 Rotation 0x0004774d main + 141
27 libdyld.dylib 0x0224cac9 start + 1
28 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I just encountered this same error testing our app under iOS 8. In our case, I took the error message at face value and changed a pattern we had in a few places.
The pattern we had to change was:
(1) in our view controller's init, instantiate a popover controller instance.
(2) on some event, set the popover controller's contentViewController property to the desired vc.
(3) call presentPopoverFromRect on the popover controller
and we simply changed step (2) to re-instantiate the popover controller with the desired content vc as an init parameter and ceased setting the contentViewController property (as we're always doing it prior to presenting the popover).
I was experiencing this same issue and finally solved it.
I have two buttons, each one shows its own popover. I was reusing the same UIPopoverController to show both of them. The first click worked fine, but then if you clicked the other one the app crashed.
The way I solved it is create a new UIPopoverController on each click:
importImagePickerControlPopoverController=[[UIPopoverController alloc] initWithContentViewController:pickerController];
[importImagePickerControlPopoverController setDelegate:self];
switch(pickerType)
{
case UIImagePickerControllerSourceTypePhotoLibrary:
case UIImagePickerControllerSourceTypeSavedPhotosAlbum:
[importImagePickerControlPopoverController setPopoverContentSize:CGSizeMake(320, 300) animated:YES];
break;
case UIImagePickerControllerSourceTypeCamera:
[importImagePickerControlPopoverController setPopoverContentSize:CGSizeMake(640, 640) animated:YES];
break;
}
[importImagePickerControlPopoverController setContentViewController:pickerController];
Similar to #user3495742 solution:
-(void)testAndSetPopoverWithVc:(UIViewController*)vc {
if (popover4Menu) {
if ([popover4Menu isPopoverVisible]) {
[popover4Menu setContentViewController:vc animated:YES];
return;
} else {
popover4Menu=nil;
}
};
popover4Menu=[[UIPopoverController alloc] initWithContentViewController:vc];
popover4Menu.delegate=self;
}
Problem rises when reassigning a view controller to an existing popover.
Free and realloc popover before assigning new content view controller: this fixed for me.
I had the same issue and this is what fixed it for me.
Try This
- (void)buttonPressed{
UIViewController *tableViewController = [UIViewController new];
//Check if the popover is nil or not visible
if(_popover == nil || _popover.popoverVisible == false){
_popover = [[UIPopoverController alloc] initWithContentViewController:tableViewController];
[_popover presentPopoverFromRect:CGRectMake(self.textField.frame.size.width / 2, self.textField.frame.size.height / 1, 1, 1) inView:self.textField permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
}else{
[_popover setContentViewController:tableViewController];
}
}
You have already have the content view controller set:
_popover = [[UIPopoverController alloc] initWithContentViewController:tableViewController];
↑
Here
So, why not just delete the line?:
[_popover setContentViewController:tableViewController];
That should work.
If popover is not visible when you are calling [_popover setContentViewController:tableViewController];, app will get crash.
Because this method should be called when popover is visible on the screen.
Make sure your popover is visible,
if(_popover != nil && [_popover isPopoverVisible] == YES)
{
[_popover setContentViewController:tableViewController];
}else
{
//create new popover object if _popover is nil or present it
}
[self.popover dismissPopoverAnimated:YES]; //in case it's already showing.
self.popover = nil; // N.B. this is not the same as popover = nil.
self.popover = [[UIPopoverController alloc] initWithContentViewController:tableViewController];
[self.popover presentPopoverFromRect:CGRectMake(self.textField.frame.size.width /
2, self.textField.frame.size.height / 1, 1, 1) inView:self.textField
permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
You do not need to create new instance of UIPopoverController neither set new contentViewController property after you first present UIPopoverViewController. (it depends on how you dismiss you popoverController)
However contentViewController can't be changed before popoverController presentation.
To workaround check popoverController.contentViewController properties. If it is nil, set conntentViewController, otherwise just present popover.
If you want to change contentViewController do it after presentation: use setContentViewController:animated: method.
Check that popoverController.isPopoverVisible before call this method.
Add these two methods into your UIwebview main class.
add <UIPopoverPresentationControllerDelegate> in your webview interface.h class as well.
define .
#property (strong, nonatomic) UIPopoverPresentationController *pop;
then
#synthesize pop;
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Assuming you've hooked this all up in a Storyboard with a popover presentation style
if ([segue.identifier isEqualToString:#"showPopover"]) {
UINavigationController *destNav = segue.destinationViewController;
pop = destNav.viewControllers.firstObject;
// This is the important part
UIPopoverPresentationController *popPC = destNav.popoverPresentationController;
popPC.delegate = self;
}
}
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
return UIModalPresentationNone;
}
I have already created a navigation controller in another class with a root view controller(the login screen). When I hit the login button I want it to push to the dashboard view controller. Here is my code
- (IBAction)logInHit:(id)sender {
if (passWord == true) {
DashBoardViewController *dash = [[DashBoardViewController alloc] initWithNibName:#"DashBoardViewController" bundle:nil];
[self.navigationController pushViewController:dash animated:YES];
}
else if (passWord == false){
UIAlertView *alert = [[UIAlertView alloc] init];
[alert setTitle:#"Incorrect Password"];
[alert setMessage:#""];
[alert setDelegate:self];
[alert addButtonWithTitle:#"Try Again"];
[alert show];
}
}
It works when it pops a view controller and it also works when it is not in the if statement but for some odd reason it breaks when using the code above. The alert view works fine! It is just the push! Please help!
In the App Delegate.h:
NavigationViewController *navView;
Here is the App Delegate (This creates an instance of the navigationController class that I made which is based off of the generic one):
LogInViewController *logInView = [[LogInViewController alloc] init];
navView = [[NavigationViewController alloc] initWithRootViewController:logInView];
[self.window addSubview:navView.view];
Here is the Log:
2014-03-06 22:15:43.552 TopOPPS REP APP[795:70b] Application windows are expected to have a root view controller at the end of application launch
2014-03-06 22:16:18.728 TopOPPS REP APP[795:70b] -[LogInViewController textEnded:]: unrecognized selector sent to instance 0x109412a90
2014-03-06 22:16:18.730 TopOPPS REP APP[795:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LogInViewController textEnded:]: unrecognized selector sent to instance 0x109412a90'
*** First throw call stack:
(
0 CoreFoundation 0x0000000101890795 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001015f3991 objc_exception_throw + 43
2 CoreFoundation 0x0000000101921bad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010188209d ___forwarding___ + 973
4 CoreFoundation 0x0000000101881c48 _CF_forwarding_prep_0 + 120
5 UIKit 0x00000001002570ae -[UIApplication sendAction:to:from:forEvent:] + 104
6 UIKit 0x0000000100257044 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17
7 UIKit 0x000000010032b450 -[UIControl _sendActionsForEvents:withEvent:] + 203
8 UIKit 0x000000010085a6d5 -[UITextField _resignFirstResponder] + 256
9 UIKit 0x000000010037ee40 -[UIResponder resignFirstResponder] + 222
10 UIKit 0x000000010085a4de -[UITextField resignFirstResponder] + 114
11 UIKit 0x000000010029b888 -[UIView setUserInteractionEnabled:] + 285
12 UIKit 0x000000010087f7b5 -[_UIViewControllerTransitionContext _disableInteractionForViews:] + 194
13 UIKit 0x0000000100364ce5 -[UINavigationController pushViewController:transition:forceImmediate:] + 1038
14 TopOPPS REP APP 0x000000010000254a -[LogInViewController logInHit:] + 202
15 UIKit 0x0000000100257096 -[UIApplication sendAction:to:from:forEvent:] + 80
16 UIKit 0x0000000100257044 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17
17 UIKit 0x000000010032b450 -[UIControl _sendActionsForEvents:withEvent:] + 203
18 UIKit 0x000000010032a9c0 -[UIControl touchesEnded:withEvent:] + 530
19 UIKit 0x000000010028bc15 -[UIWindow _sendTouchesForEvent:] + 701
20 UIKit 0x000000010028c633 -[UIWindow sendEvent:] + 988
21 UIKit 0x0000000100265fa2 -[UIApplication sendEvent:] + 211
22 UIKit 0x0000000100253d7f _UIApplicationHandleEventQueue + 9549
23 CoreFoundation 0x000000010181fec1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
24 CoreFoundation 0x000000010181f792 __CFRunLoopDoSources0 + 242
25 CoreFoundation 0x000000010183b61f __CFRunLoopRun + 767
26 CoreFoundation 0x000000010183af33 CFRunLoopRunSpecific + 467
27 GraphicsServices 0x00000001039983a0 GSEventRunModal + 161
28 UIKit 0x0000000100256043 UIApplicationMain + 1010
29 TopOPPS REP APP 0x0000000100001d53 main + 115
30 libdyld.dylib 0x0000000101f1f5fd start + 1
31 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Ok I got it!
In the NIB file of "LogInViewController", you created an Action called "textEnded", and after that you removed that method, but not the reference from the NIB.
To fix this, go to the LogInViewController NIB to see the Interface Builder, click on your UITextFields, and look inside the Connections Inspector for the method "textEnded" on the Sent Events category. After that, click on the "X" icon to remove the reference.
See this image as a reference:
1st You have to set root view Controller in appDelegate like,
LogInViewController *loginVC = [[LogInViewController alloc] initWithNibName:#"LogInViewController" bundle:nil];
UINavigationController *navController=[[UINavigationController alloc]initWithRootViewController:loginVC];
self.window.rootViewController = navController;
I think you are not familiar with if condition.
You should write like this
- (IBAction)logInHit:(id)sender {
if (passWord ) {
DashBoardViewController *dash = [[DashBoardViewController alloc] initWithNibName:#"DashBoardViewController" bundle:nil];
[self.navigationController pushViewController:dash animated:YES];
}
else {
UIAlertView *alert = [[UIAlertView alloc] init];
[alert setTitle:#"Incorrect Password"];
[alert setMessage:#""];
[alert setDelegate:self];
[alert addButtonWithTitle:#"Try Again"];
[alert show];
}
}
i checked your code its working complete fine...
but you have to set below in your appDelegate method
LogInViewController *loginVC = [[LogInViewController alloc] initWithNibName:#"LogInViewController" bundle:nil];
UINavigationController *navController=[[UINavigationController alloc]initWithRootViewController:loginVC];
self.window.rootViewController = navController;
as per your Console Log i can say that
you created one method called -(IBAction)textEnd:(id)sender{} before and linked that method to anywhere to button or textfied and now you removed that method and you forget to remove that method link from file inpector...
just double check your link from file inspector that all methods are available or not...
i got same error when i create -(IBAction)textEnd:(id)sender{} method and linked to UITextfield to EditingDidEnd action from file inpector and than i remove method whole method from my .m file and i got same error on click of login button so check your all links are have availabled linked methods
This code worked under iOS6.2; installed iOS7 and now crashes:
- (IBAction)bOpenCamera:(UIButton *)sender {
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
customerCameraFlag = YES; // indicator so text fields are not cleared
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = (id)self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects: (NSString *) kUTTypeImage, nil];
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker animated:YES completion:nil];
newMedia = YES;
}
}
I use the same code in two separate classes; neither one work. The camera never opens, just crashes when the last line (newMedia = YES) has executed. I have looked at all the entries in SO and Google, and found nothing that resembles this crash. It apparently worked on iOS 6, but I am now unable to test it because I have gone to iOS7.
Any ideas on how to fix this?
*EXC_BAD_ACCESS is not a thrown exception; it is a hard crash. Spokane-dude should post the backtrace of the actual crash.*
when running the same app on the iPad under iOS7, outside of the debugger it works fine!
I'd bet it isn't working fine. It only appears to be working, but something is still going wildly wrong, potentially corrupting user data. I'd make figuring out what a priority.
Post the crash details.
OK -- crash is here:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3b39c350 __pthread_kill + 8
1 libsystem_c.dylib 0x3b31311e pthread_kill + 54
2 libsystem_c.dylib 0x3b34f96e abort + 90
3 REDACTED.APP 0x0006aa72 0x19000 + 334450
4 Foundation 0x338a438c -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 164
5 Foundation 0x338a4088 -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] + 132
That the main thread is dispatching to itself is pretty odd and indicative of a shaky, at best, concurrency implementation.
But wait! The crash is actually further up Thread 0:
11 libsystem_c.dylib 0x3b34f96e abort + 90
12 libsystem_c.dylib 0x3b3304cc __assert_rtn + 176
13 REDACTED.APP 0x0001c3f2 0x19000 + 13298
14 UIKit 0x34e4bd18 -[UIView(CALayerDelegate) drawLayer:inContext:] + 360
15 QuartzCore 0x34bfabe0 -[CALayer drawInContext:] + 108
Whatever is in frame 13 -- some layer delegate trying to draw -- is assert()ing.
Given that it is a failed assert in a drawing method, that should narrow things down considerably.
I am writing iPad application and created DatePickerView and calling it from UIPopoverController as below:
DatePickerView *dt = [[DatePickerView alloc] initWithNibName:nil bundle:nil];
popover = [[UIPopoverController alloc] initWithContentViewController:dt];
popover.delegate = self;
[dt release];
self.popoverController = popover;
[popover release];
CGRect popoverRect = [self.view convertRect:[sender frame] fromView:[sender superview]];
popoverRect.size.width = MIN(popoverRect.size.width, 100);
[self.popoverController presentPopoverFromRect:popoverRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
In the DatePickerView i have below code when the "Done" button is selected, this is basically sending the selected date with formatter back to main UI by using appdelegate:
.h
I
BOutlet UIDatePicker *dtPicker;
-(IBAction) btnSelectClicked:(UIButton *)sender
{
MachineDetailsView *appDelegate;
appDelegate = (MachineDetailsView *)[[UIApplication sharedApplication] delegate];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:#"MM/dd/YYYY"];
NSDate *dt = [dtPicker date];
appDelegate.backPickerStartDate = [formatter stringFromDate:dt];
}
in MachineDetailsView i declared backPickerStartDate as below:
.h: file details
NSString *backPickerStartDate;
UIPopoverController *popoverController;
UIPopoverController *popover;
....
#property(nonatomic, retain) NSString *backPickerStartDate;
....
.m: file details
#synthesize backPickerStartDate;
I am getting below error when i click on "Done" button of DatePickerView
2011-03-23 11:46:59.813 iMobile[22492:40b] -[iMobileAppDelegate setBackPickerStartDate:]: unrecognized selector sent to instance 0x8a3dc00
2011-03-23 11:46:59.816 iMobile[22492:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[iMobileAppDelegate setBackPickerStartDate:]: unrecognized selector sent to instance 0x8a3dc00'
*** Call stack at first throw:
(
0 CoreFoundation 0x00df9be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f4e5c2 objc_exception_throw + 47
2 CoreFoundation 0x00dfb6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d6b366 ___forwarding___ + 966
4 CoreFoundation 0x00d6af22 _CF_forwarding_prep_0 + 50
5 UIKit 0x00302a6e -[UIApplication sendAction:to:from:forEvent:] + 119
6 UIKit 0x003911b5 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x00393647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
8 UIKit 0x003921f4 -[UIControl touchesEnded:withEvent:] + 458
9 UIKit 0x003270d1 -[UIWindow _sendTouchesForEvent:] + 567
10 UIKit 0x0030837a -[UIApplication sendEvent:] + 447
11 UIKit 0x0030d732 _UIApplicationHandleEvent + 7576
12 GraphicsServices 0x0172fa36 PurpleEventCallback + 1550
13 CoreFoundation 0x00ddb064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
14 CoreFoundation 0x00d3b6f7 __CFRunLoopDoSource1 + 215
15 CoreFoundation 0x00d38983 __CFRunLoopRun + 979
16 CoreFoundation 0x00d38240 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x00d38161 CFRunLoopRunInMode + 97
18 GraphicsServices 0x0172e268 GSEventRunModal + 217
19 GraphicsServices 0x0172e32d GSEventRun + 115
20 UIKit 0x0031142e UIApplicationMain + 1160
21 iG2Mobile 0x000022f2 main + 84
22 iG2Mobile 0x00002295 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
ANY HELP IS GREATLY APPRECIATED. Please let me know if any further details are needed.
I also added below setter method to MachineDetailsView but still no use:
-(void)setBackPickerStartDate:(NSString *)newBackPickerStartDate
{
if (backPickerStartDate != newBackPickerStartDate) {
backPickerStartDate = newBackPickerStartDate;
}
}
Thank you very much
You've stated that you've declared and synthesize the backPickerStartDate property in the MachineDetailsView class, yet you call it on an instance of iMobileAppDelegate in btnSelectClicked:
appDelegate.backPickerStartDate = [formatter stringFromDate:dt];
A few lines above, you have this:
MachineDetailsView *appDelegate;
appDelegate = (MachineDetailsView *)[[UIApplication sharedApplication] delegate];
That's wrong because you cast the pointer to your app delegate to a pointer to MachineDetailsView. That doesn't make your app delegate object magically turn into a MachineDetailsView object. What you need instead is a getter method or property that returns your MachineDetailsView object (or find another way to access it).
[iMobileAppDelegate setBackPickerStartDate:]: unrecognized selector sent to instance
As per the Exception above, you need to declare backPickerStartDate in your app delegate.