I would like to have choosing images or videos as one option when taking photos or videos. When i seem to click the option, the app crashes. I am using ios 6 and it seems that apple has included some privacy issues when the app tries to search for existing images and videos. Besides that, should i still be using UIImagePickerControllerSourceTypeSavedPhotosAlbum or use something else?
Part of my code:
if (buttonIndex == 2) {
imgpPicker = [[UIImagePickerController alloc] init];
imgpPicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
imgpPicker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie,(NSString *)kUTTypeImage,nil];
popOverView = [[UIPopoverController alloc] initWithContentViewController:imgpPicker];
[popOverView presentPopoverFromRect:self.view.bounds inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
The error that appears on the debugger is signal SIGABRT:
*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'
*** First throw call stack:
(0x36a732a3 0x33e9a97f 0x36a731c5 0x3777d897 0x3777d6a1 0x3777d65b 0x3777ce1b 0x3777cb45 0x37735767 0x377355c7 0x377355c7 0x3772fe53 0x377177e5 0x377172cb 0x37b00b95 0x115313 0x378d6ccb 0x378000ad 0x3780005f 0x3780003d 0x377ff8f3 0x377ffde9 0x377285f9 0x37715809 0x37715123 0x3644d5a3 0x3644d1d3 0x36a48173 0x36a48117 0x36a46f99 0x369b9ebd 0x369b9d49 0x3644c2eb 0x37769301 0xe1763 0xe14c0)
libc++abi.dylib: terminate called throwing an exception
(lldb)
The privacy for the application is also set to ON in the settings.
Am i doing something wrong?
Any guidance or tips will be very helpful. Sorry if the question is very vague.. If need more information, I can provide...
In your code add:
- (BOOL)shouldAutorotate
{
return YES;
}
And go to the summary tab of your application and allow both portrait and landscape orientations.
Related
I have a view controller opening an 'Open-In' dialogue via a bar button item.
Calling code:
UIDocumentInteractionController *docInteraction = [[UIDocumentInteractionController alloc] init];
docInteraction.URL = location;
docInteraction.delegate = self;
if ([docInteraction presentOpenInMenuFromBarButtonItem:self.openInButton animated:YES])
self.openInController = docInteraction;
Dismissal code:
UIDocumentInteractionController *openIn = self.openInController;
if (openIn) {
[openIn dismissMenuAnimated:animated];
self.openInController = nil;
popupsDismissed = YES;
}
Sometime after the code is dismissed, the app crashes with this exception:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[A2DynamicUIPopoverControllerDelegate popoverController:animationCompleted:]: unrecognized selector sent to instance 0x1f82b4f0'
This is a BlocksKit defined interface, but I'm not using a BlocksKit class in thie particular case. 0x1f82b4f0 is a <A2DynamicDelegate: 0x1f82b4f0; protocol = UIPopoverControllerDelegate> but why BlocksKit is involved here at all is a mystery. Can someone give me some insight on how to fix the exception?
BlocksKit is a bit of a red herring. The dismissal code is deallocating the UIDocumentInteractionController too early here:
self.openInController = nil;
At the earliest, the deallocation should happen after the -documentInteractionControllerDidDismissOpenInMenu: delegate callback method.
I have an application where I am displaying a video on a view. But when the video is displayed it is getting crashed when I click on the full screen mode in iOS. This is my code:
-(void)viewDidLoad
{
MPMoviePlayerController *mc = [[MPMoviePlayerController alloc] initWithContentURL:nil];
mc.shouldAutoplay = NO;
mc.controlStyle = MPMovieControlStyleEmbedded;
NSURL *contentURL = [[NSBundle mainBundle] URLForResource:#"01 01. Welcome" withExtension:#"mov"];
mc.contentURL = contentURL;
[mc prepareToPlay];
mc.view.frame = self.test.bounds;
[self.test addSubview:mc.view];
self.testvideo = mc;
testvideo.fullscreen=YES;
}
I am adding player controller on to another view named test. When I click on the full screen buttons the app is getting crashed displaying error messages:
-[UIView trackRectForBounds:]: unrecognized selector sent to instance 0xa171ec0
2013-09-03 15:49:35.178 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView trackRectForBounds:]: unrecognized selector sent to instance 0xa171ec0'
Not sure why your app is crashing in the code snippet you've provided because the trackRectForBounds method is found on the UISlider class. Are you using a slider anywhere in your app ?
I'd suggest you to try the MPMoviePlayerViewController class instead of the MPMoviePlayerController class.
You can refer to this SO question for more details.
I've been struggling with this issue for a while now and I just can't seem to reproduce it accurately enough to describe the exact use-case. Essentially, what I'm doing is issuing a request for opening a native iOS 6.0 Facebook share dialog (using the Facebook iOS SDK 3.1.1):
if ([[SocialManager sharedManager] isNativeFacebookShareDialogAvailable]) {
if (!url) {
url = [NSURL URLWithString:#""];
}
if (!imageUrl) {
imageUrl = [NSURL URLWithString:#""];
}
dispatch_async(backgroundQueue, ^{
NSData *imageData = [NSData dataWithContentsOfURL:imageUrl];
UIImage *image = [UIImage imageWithData:imageData];
if (!image) {
image = [[UIImage alloc] init];
}
if ([FBNativeDialogs canPresentShareDialogWithSession:[FBSession activeSession]]) {
dispatch_async(dispatch_get_main_queue(), ^{
[FBNativeDialogs presentShareDialogModallyFrom:sender initialText:initialText images:#[image] urls:#[url] handler:^(FBNativeDialogResult result, NSError *error) {
if (error) {
failBlock([[error userInfo] description]);
} else {
if (result == FBNativeDialogResultSucceeded) {
completionBlock();
} else if (result == FBNativeDialogResultCancelled) {
failBlock(#"User cancelled");
} else if (result == FBNativeDialogResultError) {
failBlock(#"Unknown error");
}
}
}];
});
} else {
LogErr(#"Can't display native share dialog for active session");
}
});
}
Right after presentShareDialogModallyFrom:sender is called, I either get the following crash log:
*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x1d161490> was mutated while being enumerated.'
*** First throw call stack:
(0x32ede2a3 0x326b097f 0x32eddd85 0x35da094d 0x32edb62f 0x35da07f5 0x35e7e5e5 0x35e0ccd7 0x35e0cb6d 0x372c490f 0x35e0ca61 0x35e160d5 0x372b783b 0x35e160b1 0x372b711f 0x372b699b 0x372b6895 0x372c5215 0x372c53b9 0x36f5fa11 0x36f5f8a4)
libc++abi.dylib: terminate called throwing an exception
OR I get no crash and the native share dialog appears as it should.
The stack implies a call on a thread called UIRemoteViewControllerCreationRequest at this point, here are 2 examples for two different crashes:
Thanks for your help
After a lot of experimenting with my application and looking into Facebook SDK source I realized 3 things:
Creating a SLComposeViewController by yourself doesn't help. Facebook SDK is pretty simple in this, it just creates the controller exactly like the code in the answer with bonus.
When you are authorizing the FB session, your application is deactivated once or more times. This is caused by the permission confirmation alerts appearing.
The UIRemoteViewController is actually the SLComposeViewController which is run in a different process.
What caused my error?
User confirms FB permissions
This triggers applicationDidBecomeActive:
It also triggers FB callback to present the dialog.
My applicationDidBecomeActive: was doing something with the UI what was not supposed to be done when the FB dialogs were appearing (tirggering a table reload).
Also, there is another thing to be careful of - the handler of presentShareDialogModallyFrom... is not called on any particular thread (see SLComposeViewController docs). That means that you should use dispatch_async(dispatch_get_main_queue(), ...) from the handler if you are updating UI from it.
EDIT:
Obviously, the previous steps fixed some crashes but one of the crashes was not solved. After a lot of googling and searching Apple Developer forums, I think there is a bug in iOS 6 connected with Remote Controllers and using UIAppearance, especially the appearance of UINavigationBar. I am currently removing the use of UIApperance from my app.
This is a very strange way to post a post to Facebook. Here is a much simpler way that never crashes.
ViewController.h
#import <UIKit/UIKit.h>
#import <Social/Social.h>
#import <Accounts/Accounts.h>
#interface ViewController : UIViewController {
SLComposeViewController *mySLComposerSheet;
}
- (IBAction)PostToFacebook:(id)sender;
#end
ViewController.m
#implementation ViewController
- (IBAction)PostToFacebook:(id)sender {
mySLComposerSheet = [[SLComposeViewController alloc] init];
mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySLComposerSheet setInitialText:#"Place Text Here"];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}
#end
If needed, there is a video here.
Sorry some of this is rather guessing, but I thought I would try:
Are you sure that canPresentShareDialogWithSession is safe to call from a non-UI thread?
You have a line in both stacks of _NSDictionaryEnumerate. It looks like from higher functions, that something is calling enumerateKeysAndObjectsUsingBlock:.
Based on your note of things crashing just after [presentShareDialogModallyFrom:sender]. Is there something being released when sender's view disappears?
Variable "image" is either retained or autoreleased depending on which code path it took.
I think the problem is what Walt already said. In your code, something is done outside the main thread.
In the crash log you can see that someone is setting the appearance (UIAppearance) on some UI element from a non-UI thread. That's the problem. This operation MUST be done ONLY in the UI (main) thread.
I believe this has to do with the combination of the UIAppearance methods and launching a UIRemoteViewController from a background thread. We're having the same issue in our app. I'm going to change our presenter class to present all our remote viewControllers from the main thread and see if that helps.
In your case, I guess something in the Facebook SDK is presenting something from a background thread.
I'll update after I've verified that my fix works.
This is a bug in iOS 6 and Social Framework, check answer here UINavigationBar appearance and Facebook-Sheet Bug
How to solve this?
Simply instead of using [UINavigationBar appearance] use [UINavigationBar appearanceWhenContainedIn:...]
You can use custom class for your navigation controller (eg. CustomNavigationController) and then apply it in appearance:
[UINavigationBar appearanceWhenContainedIn:[CustomNavigationController class], nil]
From my experiments it should be used on all appearance methods, not only UINavigationBar but also UIBarButtonItem etc. (on every object you send appearance message to)
I think you know what is obvious but I met this error once and it was an NSMutableArray that was mutated while being enumerated inside a for..in statement.
Look at the NSMutableArray, you'll find your error.
Byt the way, if you target ios6, why don't you use the social framework with native facebook implementation ?
I am making an app wherein when I load the app and change the orientation, it is able to handle the orientation. But if I tap on any TableViewCell in RootViewController to display a table in DetailViewController for a splitViewBased app and then change the orientation then my app crashes with SIGABRT and gives the following message :
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_UITableViewReorderingSupport count]: unrecognized selector sent to instance 0x4e4eb30'
The method that I am writing to handle orientation is :
// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
//hot fix sometimes in multilevel bar button is shown in landscape mode.
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
[[self navigationItem] setLeftBarButtonItem:nil];
}
else {
[[self navigationItem] setLeftBarButtonItem:self.appDelegate.rootPopoverButtonItem];
}
return YES;
}
You would most probably be using an array to load the contents to the table, and at the point of reloading or filling the table with contents, the array count might be 0 or the array instance would have lost its scope, and you would be trying to access it directly from cellForRowAtIndexPath delegate. If it is so, then try retaining the array, or allocating it.
Add NSLog after the if and else to make sure it's reading each one and see if where the crash is. If there's the didRotateTo or didRotateFrom, add NSLog there too to see what's going on.
Also try just return YES: in the shouldAutorotate and nix the if/else to make sure it does rotate properly and there's nothing else getting in the way.
Lastly, check your Target > Supported Device Orientation to make sure all orientations are supported
In my iPad application, I'm letting the user select an image using the following code:
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
self.popoverController = popover;
popoverController.delegate = self;
[popoverController presentPopoverFromRect:self.view.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
[picker release];
(I've set up the class to be both a UIPopoverControllerDelegate and a UIImagePickerControllerDelegate, and I've setup the callbacks for both delegates.)
Now, the weird thing is that if I select an image from the "Saved Photos" photo album, my "imagePickerController: didFinishPickingImage" callback method gets called, and I get an image, and all is well.
But, if I select an image from any of the other albums, my "imagePickerControllerDidCancel" callback gets called - and I don't get back an image.
Any idea? I've searched the web high-and-low...
Thanks,
Reuven
The plot thickens...
When adding:
allowsEditing = YES;
I can still select (and crop/scale) images from the Saved Photos album - but when trying to Use images from other albums, the iPad crashes with the debugger showing:
2010-06-03 08:16:06.759 uPrintMobile[98412:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: UIImagePickerControllerOriginalImage)'
Still no clue...
I know this is many months later, but I struggled with the same problem and found that though it was asked here many times, it was never answered. Well, I'm happy to say that I figured it out and so am posting it on a few of the nearly-identical questions that come up first on a search.
I posted the full answer here:
didFinishPickingMediaWithInfo return nil photo
Try playing around the other options of UIImagePickerControllerSourceTypePhotoLibrary
in your delegate method, check the condition like
`if( image is from photo library ) {
// do something
} else if ( image from saved albums ) {
// do something
}`