Unusual NSInternalInconsistencyException related to device orientation - ios

I am getting an unusual error on an iPad app I am working on:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'Card''
*** First throw call stack:
(0x35ef988f 0x31872259 0x37aee7e5 0x8aadd 0x30a35e33 0x30a42391 0x30a42201 0x30a420e7 0x30a41969 0x30a416ab 0x30a4156b 0x30a000bd 0x35e581fb 0x37349aa5 0x373496bd 0x373495c9 0x30b7ea73 0x30ae0b1f 0x30b7212b 0x30b720bb 0x30a40ba9 0x30bb8927 0x34c6e2e9 0x34c6de23 0x30bbeae9 0x34c47f09 0x35e587d3 0x35e59461 0x30c741af 0x30c7594d 0x30bab509 0x30a34893 0x30a2e8d7 0x309fcc6b 0x309fc70f 0x309fc0e3 0x35bcf22b 0x35ecd523 0x35ecd4c5 0x35ecc313 0x35e4f4a5 0x35e4f36d 0x30a2da13 0x30a2ae7d 0x83631 0x835f0)
This occurs only when I change my view controllers shouldAutorotateToInterfaceOrientation from:
return YES;
to:
if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight)
return YES;
return NO;
Why would this cause an NSInternalInconsistencyException?
I did notice when debugging, that shouldAutorotateToInterfaceOrientation gets called about 20 times by the same function: [UIViewController _isSupportedInterfaceOrientation:]. This is not done recursively.
My app only has Landscape (left) and Landscape (right) in the supported orientations and Landscape (left) as the intial orientation
Thanks in advance.

Related

App crash when MFMessageComposeViewController is initialisation

I want to send a message through my app. I call the following method on click
#IBAction func sendMessage(_ sender: Any) {
if (MFMessageComposeViewController.canSendText()) {
let composeVC = MFMessageComposeViewController()
composeVC.messageComposeDelegate = self
// Configure the fields of the interface.
composeVC.recipients = ["4085551212"]
composeVC.body = "Hello from California!"
// Present the view controller modally.
self.presentViewController(composeVC, animated: true, completion: nil)
}
}
The problem is if I run the app on device, it crashes at MFMessageComposeViewController initialisation i.e.
let composeVC = MFMessageComposeViewController()
If I run the app in simulator, it crashes on presentation i.e.
self.present(composeVC, animated: true, completion: nil)
Error log when I run the app on device
2018-01-29 12:03:57.826816+0530 EWS[2495:806400] *** Assertion failure in -[UICGColor encodeWithCoder:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3698.33.7/UIColor.m:1722
2018-01-29 12:03:57.827522+0530 EWS[2495:806400] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only RGBA or White color spaces are supported in this situation.'
*** First throw call stack:
(0x183702364 0x182948528 0x183702238 0x18409d7f4 0x18d08fffc 0x1840574dc 0x18405e8d8 0x18d4ebf20 0x18d4eb74c 0x18d4e7044 0x1835d03c0 0x18d4e6d44 0x18d7f16fc 0x18d60bd18 0x18d60b94c 0x19aee4534 0x19aecbff4 0x19aecc314 0x1984ce830 0x101159ec0 0x101158888 0x1011584b4 0x1011589c0 0x18cc186b4 0x18cc18634 0x18cc031dc 0x18cc17f28 0x18cc17a48 0x18cc12f60 0x18cbe3f64 0x18d53931c 0x18d53b8a8 0x18d5347c0 0x1836aa97c 0x1836aa8fc 0x1836aa184 0x1836a7d5c 0x1835c7e58 0x185474f84 0x18cc4767c 0x101157170 0x1830e456c)
libc++abi.dylib: terminating with uncaught exception of type NSException
Error log when I run the app on simulator (without checking if(MFMessageComposeViewController.canSendText()))
2018-01-29 12:07:49.395714+0530 EWS[3533:67163] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target <EWS.BlockVC: 0x7f899c61db10>.'
*** First throw call stack:
Any help would be appreciated.
Okay,
When you run it in iPhone : The crash log clearly states that "Only RGBA or White color spaces are supported in this situation." So by hint I would say you are assigning color somewhere, (Some Global tint, navigation bar tint) , which doesn't apply to a MFMessageComposeViewController, hence its crashing.
When you run it in the simulator :
if (MFMessageComposeViewController.canSendText()), this line will prevent it from initialising the MFMessageComposeViewController, in the simulator as it cant send text, hence when you try to present it, its not yet initialised and crashing.
On a second thought, as per your code : self.presentViewController(composeVC, animated: true, completion: nil), this line should not even be called while running in the simulator as this line is inside the if statement, which wont get through.
Also change the tint color or any while initialising the controller, and tell me what the results are.

Open UIImagePickerController in landscape

I am trying to present UIImagePickerController in landscape mode for iPhone, as my application supports only landscape mode.Which works fine with iOS 11.But whenever I run my application in iOS 10.3.3 it gets crash the same time with error :
*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES' * First throw call stack:**
Create an extension of UIImagePickerController like below
extension UIImagePickerController
{
override open var shouldAutorotate: Bool {
return true
}
override open var supportedInterfaceOrientations : UIInterfaceOrientationMask {
return .all
}
}
Hope that will help you

Assertion failure from Cocos2d CCNode.m on iOS device. Fine in simulator. Why?

Can anyone shed any light on the reason for the following failure:
*** Assertion failure in -[Alien rotation],
/Users/admininstrator/Documents/moonweed/Star Pilot v4.0/Star Pilot
#1/Libraries/cocos2d/CCNode.m:258
2014-11-06 23:28:51.680 Star Pilot #1[2141:987748] *** Terminating app due to uncaught
exception 'NSInternalInconsistencyException', reason: 'CCNode#rotation. rotationalSkewX
!= rotationalSkewY. Don't know which one to return'
Looking at the Cocos2d source, I can see that the Assertion is coming from CCNode.m, from the method below:
-(float) rotation
{
CCPhysicsBody *body = GetBodyIfRunning(self);
if(body){
return -CC_RADIANS_TO_DEGREES(body.absoluteRadians) +
NodeToPhysicsRotation(self.parent);
} else {
NSAssert( _rotationalSkewX == _rotationalSkewY, #"CCNode#rotation. rotationalSkewX != rotationalSkewY. Don't know which one to return");
return _rotationalSkewX;
}
}
The code runs fine on all simulators, using Xcode 6.1. But on my iPhone 5, it crashes. I'm struggling to figure why? I'm currently using Cocos2d V3.x.

Mapbox NSInternalInconsistencyException showing RMMapView on iPad

Having a spot of trouble trying to get the native iOS Mapbox view working on an actual device (3rd gen iPad, iOS 7.1).
dprintf( "RMMapboxSource\n" );
RMMapboxSource * tileSource = [[RMMapboxSource alloc] initWithMapID:mystyle];
dprintf( "RMMapView\n" );
RMMapView * mapView = [[RMMapView alloc] initWithFrame:CGRectMake(0,0,900,450) andTilesource:tileSource];
dprintf( "addChild\n" );
// ... mapView then added to view hierarchy
dprintf( "setPage\n" );
// ... then make visible
Everything works great in the simulator. But trying to run on an actual iPad results in the following.
RMMapboxSource
RMMapView
addChild
setPage
2014-04-01 15:41:21.879 Protraak[1179:60b] *** Assertion failure in -[UIView layoutSubviews], /SourceCache/UIKit/UIKit-2935.137/UIView.m:5326
2014-04-01 15:41:21.881 Protraak[1179:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'layout should have been successfully accomplished'
A Google search for "layout should have been successfully accomplished" came up blank.
Can you try the latest develop branch and see if that works for you?

UITextFieldView markedTextRange crash on iOS4?

My apps use UITextFieldView to receive input method from user and work fine on iOS6/iOS7. and I am using the following code to prevent user input chinese/japanese/something like that. Method to detect the real input words:
-(void)textFieldChanged:(UITextField *)textField
//crash here if device iOS version at 4.3
UITextRange *selectRange = [textField markedTextRange];
if (selectRange == nil)
//get word to do something...
Crash log :
2013-11-20 12:35:09.480 [My app][203:607]-[UITextField markedTextRange]: unrecognized selector sent to instance 0x287e270
2013-11-20 12:35:09.480 [My app][203:607] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextField markedTextRange]: unrecognized selector sent to instance 0x287e270'

Resources