How to debug iOS7 shadowOffset crash - ios

My app works fine on ios6. I made a copy and ran it on Xcode5 and it launches but a few seconds later it crashes with this error:
[UIDeviceRGBColor shadowOffset]: unrecognized selector sent to instance
I had some tableviewcontroller lines like this:
//[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
but I commented them all out thinking they were the issue. What else could be causing the crash?

//do this to see if the selector exists replace dismissViewController... with your selector that you want to check
if ([self respondsToSelector:#selector(dismissViewControllerAnimated:completion:)])
{[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];} //post-iOS6.0
else {[self dismissModalViewControllerAnimated:YES];} //pre-iOS6.0

Related

Crash in self.view after constructor on iOS 8.1 and 8.2

I'm trying to do a simple SpriteKit action - adding a view to a scene:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"LevelsEditorStoryboard" bundle:[NSBundle mainBundle]];
self.levelsEditor = [mainStoryboard instantiateViewControllerWithIdentifier:#"LevelsEditorId"];
[self.scene.view addSubview:self.levelsEditor.view];
On iOS 8.0 and 8.3 is working fine and on iOS 8.1 and 8.2 I'm getting the following error:
SPBingo[75304:80943666] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextSelectionView name]: unrecognized selector sent to instance
I realised that this crash caused by the UITextField.
Once I'm getting rid of it, replacing the UITextField with some UITextView ( not ideal but whatever) The view is loading but when I try to click on a UITextView it crashed. The other Input views work (switches, dataPicker, tableView etc.)
After a deep dive into it I figured out that the problem occur in the contractor already. When I put breakpoint on the the second line in the following code :
-(instancetype) initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if(self)
{
}
return self;
}
and try to print "self.view" I'm getting the following error:
error: Execution was interrupted, reason: internal ObjC exception breakpoint(-3)..
The process has been returned to the state before expression evaluation.
ODD!
You cannot access the view until after the "viewDidLoad:" method signature is called, otherwise it attempts to create the view before all the prerequisites are in place.
Make sure to call self.view from "viewDidLoad:", "viewWillAppear:" or "viewDidAppear:" when it has properly been setup.
So.. it is an internal bug by Apple which create in 8.1 and fixed in 8.3.
The solution is avoid using the UITextView contractor "initWithFrame" and use the following one:
UITextView *textView = [[UITextView alloc] initWithFrame: frame textContainer: textContainer];

ios application crashed with "message send to deallocated instance"

My app crashed and the code is the following:
else if(...)
{
CGDetailView *detailView = [[CGDetailView alloc] init];
ContactGroup *contactGroup = [[ContactGroup alloc] init];
[contactGroup setObjectStatus:NewObject];
[detailView setContactGroup:contactGroup];
[detailView newContactGroup:YES];
[contactGroup release];
UIBarButtonItem *temporaryItem=[[UIBarButtonItem alloc] init];
temporaryItem.title = NSLocalizedString(#"back", #"");
self.navigationItem.backBarButtonItem = temporaryItem;
[temporaryItem release];
[[self navigationController] pushViewController:detailView animated:YES];
[detailView release];
}
The error is "message sent to deallocated instance" and it regards the object of type
CGDetailView. I use the alloc-init-release pattern, and I don't really understand why the
app crashed. It usually works.
iOS 7.1 and device is iPhone5 if that helps.
Just try to get the point where your memory is released for this CGDetailView's object and you still calling a method on that object.
You can do it by enabling Zombie Object from edit scheme, it will tell you the point where your app is crashing.

Azure Mobile Services crash

Using the ios WindowsAzureMobileServices.framework (v1.2.3) I get an [NSArray insertObject:atIndex] exception (object cannot be nil) in code I don't control when I use the following code to present a MSLoginController.
MSLoginController *loginController =
[self.client
loginViewControllerWithProvider:provider
completion:^(MSUser *user, NSError *error)
{
//some code
}];
[controller presentViewController:loginController animated:YES completion:nil];
Any one have ideas how to rectify? Or why this is occurring?
I expanded the stack trace when the crash occurs and discovered UIAppearance calls were in the stack when the UIViewController was presented. After some digging into our appearance customization code the following code causes the crash:
[[UIBarButtonItem appearance] setStyle:UIBarButtonItemStylePlain];
The Azure library uses the UIToolbar in a different manner than was used elsewhere in the app and produced the exception.

Cannot show modal ViewController in iOS7

I tried to show system defined viewcontrollers (MFMailComposeViewController, TWTweetComposeViewController,etc..) as a modal view.
But these viewcontrollers dosn't appear in iOS 7(these run in iOS5,iOS6).
Viewcontrollers created by me appear in iOS7(ex.HogeViewController).
I don't call presentViewController:animated:completion at viewDidLoad or viewWillAppear.
Does anybody have an idea?
Console logs:
init Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)"
or
_serviceViewControllerReady:error: Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)"
or
Unbalanced calls to begin/end appearance transitions for .
TWTweetComposeViewController(doesn't appear)
TWTweetComposeViewController *viewController = [[TWTweetComposeViewController alloc]init];
viewController.completionHandler = ^(TWTweetComposeViewControllerResult result){
NSLog(#"Result : %d",result);
};
[self presentViewController:viewController animated:YES completion:NULL];
Log
Result : 0
MFMailComposeViewController(appears a moment and dismiss soon)
- (void)send:(NSString*)email{
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSArray *toRecipients = #[email];
[picker setToRecipients:toRecipients];
[picker setSubject:#"Subject"];
[picker setMessageBody:#"Body" isHTML:NO];
[self.navigationController presentViewController:picker animated:YES completion:NULL];
}
}
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
[self dismissViewControllerAnimated:YES completion:^{
NSLog(#"error:%#,result:%d",error.description,result);
}];
}
Log
_serviceViewControllerReady:error: Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)"
Unbalanced calls to begin/end appearance transitions for .
error:(null),result:0
Turns out the issue only shows up when customizing UIBarButtons. If we use the following in our 32-bit app running on iPhone 5s, we have the problem:
[[UIBarButtonItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, 1.0)
forBarMetrics:UIBarMetricsDefault];
Leaving out that line works around the problem. We have filed a radar.
This is an issue when you do not compile for 64bit (arm64) in your project settings. Though this may not always be an option for some people because currently Google Analytics does not support the 64bit devices.
You may be able to avoid this issue with some subclassing. I was having the same issue, and in my case the culprit was:
[[UISearchBar appearance] setSearchTextPositionAdjustment:UIOffsetMake(15.0f, 0.0f)];
I was already using a subclass of UISearchBar anyway, so I changed that to:
[[KA_SearchBar appearance] setSearchTextPositionAdjustment:UIOffsetMake(15.0f, 0.0f)];
That's resolved the issue for me. Only tested on an iPhone 5s, iOS 7.0.3.
I am getting the same behavior in the same situations. In my case it turned out to be caused by using the "setSeparatorInset" appearance selector of UITableView. Getting rid of that fixed the problem. This looks like a bug on Apple's end for sure, but at least there is a workaround.
This question shows someone having a similar problem and in their case getting rid of a UISearchBar appearance selector fixed it. So something is wrong with some of these UIAppearance selectors.
This post helped me find a solution to a similar issue. But my problem was not related to the tab bar, so I figured I'd share if anyone else comes across this post:
The mail modal opened when tapping a table cell, but would instantly dismiss. In my case, this code caused the problem:
[[UILabel appearanceWhenContainedIn:[UITableViewHeaderFooterView class], nil] setFont:[UIFont systemFontOfSize:17.0]];
I deleted it, and everything works!
In My case, following code will cause the same issue on 64bit machine or simulator. Hope for helping someone met this issue.
if ([UITableViewCell instancesRespondToSelector:#selector(setSeparatorInset:)]) {
[[UITableViewCell appearance] setSeparatorInset:UIEdgeInsetsZero];
}
This Problem occurs in iPad air (64 bit) when app is not complied for 64 architecture. The problem I encountered was every UIAppearance selector which try to use UIOffsetMake/UIOffsetZero doesn't work properly!
example
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(1.0, 1.0) forBarMetrics:UIBarMetricsDefault];
or
[[UITableViewCell appearance] setSeparatorInset:UIEdgeInsetsMake(0, 5, 0, 5)];
I think its a bug in Apple code and I tried few things but nothing works. Better if you can comment out places where you setInsets in UIAppearance selectors
I had the same error when use SLComposeViewController to share with Facebook or Twitter using the simulator of 64-Bits or an iPhone 5s, then i delete every line of code that use "appearance, for example [UITableViewCell appearance] or [UIBarButtonItem appearance], and every run ok.
I updated xcode to version 5.1 and it worked ok now.
NSXPCConnectionInterrupted = 4097. I would have your code retry the command as the error looks to be transient.

Choosing From Library using UIImagePickerControllerSourceTypeSavedPhotosAlbum

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.

Resources