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.
Related
Currently getting the following runtime exception
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Animator <UIViewPropertyAnimator(0x600003f24200) [stopped] interruptible> is already stopped!'
Because of the following line of code
// other code up here that modifies offsetAnimator
...
// stop any current running animations on offset
if let offsetAnimator = offsetAnimator {
offsetAnimator.stopAnimation(false) // this line is where the exception gets raised
offsetAnimator.finishAnimation(at: .end)
}
What is perplexing, however, is why this error is NOT readily reproducible
// doing this doesn't always result in an error
if let offsetAnimator = offsetAnimator {
offsetAnimator.stopAnimation(false)
offsetAnimator.finishAnimation(at: .end)
offsetAnimator.stopAnimation(false)
offsetAnimator.finishAnimation(at: .end)
}
What on earth is happening? Can someone explain to me why this error is occurring?
Why does it seem to only happen sporadically? Shouldn't calling .stop twice always trigger it?
I'm working on a simple app that just shows the time and battery level. The time part works flawlessly, and I can monitor the battery level, but the battery indicator icon crashes the app when there are any changes to the device's battery. Here's the relevant code:
override func viewDidLoad() {
super.viewDidLoad()
UIDevice.current.isBatteryMonitoringEnabled = true // Enable battery monitoring
NotificationCenter.default.addObserver(self, selector: Selector(("batteryStateDidChange:")), name: NSNotification.Name.UIDeviceBatteryStateDidChange, object: nil) // Add battery state checker
NotificationCenter.default.addObserver(self, selector: Selector(("batteryLevelDidChange:")), name: NSNotification.Name.UIDeviceBatteryLevelDidChange, object: nil) // Add battery level checker
// Get the battery level
var batteryLevel: Int {
return Int(UIDevice.current.batteryLevel * 100)
}
update()
timer = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(self.update), userInfo: nil, repeats: true) // Start the timed scheduler
}
Here's the error:
2017-06-24 11:45:27.783761-0500 SimpleClock[1484:846193] -[SimpleClock.ViewController batteryLevelDidChange:]: unrecognized selector sent to instance 0x15dd15bc0
2017-06-24 11:45:27.785656-0500 SimpleClock[1484:846193] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SimpleClock.ViewController batteryLevelDidChange:]: unrecognized selector sent to instance 0x15dd15bc0'
*** First throw call stack:
(0x181c65858 0x18043c528 0x181c72a6c 0x188815140 0x181c6af68 0x181b4ce5c 0x181bf3004 0x181bf25a4 0x181bf2308 0x181c74268 0x181b2a4e4 0x1826f32d4 0x1884abd60 0x1884abbc8 0x181ecdaf0 0x181beda68 0x181c0cbc8 0x181c0c370 0x181c09d80 0x181b28280 0x183639f94 0x1884d70f0 0x100da10e4 0x180919e40)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
The -[SimpleClock.ViewController batteryLevelDidChange:]: unrecognised selector error indicates that the batteryLevelDidChange function is missing in the code or as Vadian commented, the signature is wrong.
Use an if condition before adding the observer for batteryStateDidChange: selector. You can use respondsToSelector: method for this. This way you can make sure if the selector is implemented.
Also you need to implement the selector in your source file as I can't see it in your code, hence giving the unrecognised selector error.
Hope it helps!
I am using applozic chat sdk for ios and sending images , video successfully . My requirement is to change camera overlay. When I try to add overlay on camera it crashes.
let camaraObj : ALImagePickerController = ALImagePickerController()
let overlay =UIView(frame: UIScreen.mainScreen().bounds)
overlay.backgroundColor = UIColor.redColor()
camaraObj.cameraOverlayView = overlay
Crash log: libc++abi.dylib: terminating with uncaught exception of type NSException.
Any help ?
Looks like you are not setting the sourceType. ALImagePickerController is used for sending pictures from photos only. You need to explicitly set source type if you want to use it for camera.
i.e. self.mImagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
We just tried the same and got below exception:
2017-01-30 14:30:30.954540 applozicdemo[3106:1925853] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Source type must be UIImagePickerControllerSourceTypeCamera' First throw call stack:
(0x1819de1c0 0x18041855c 0x187a945cc 0x187d23294 0x1003f9dcc 0x10016525c 0x10016521c 0x10016a284 0x18198bf2c 0x181989b18 0x1818b8048 0x18333e198 0x1878a42fc 0x18789f034 0x1000517b8 0x18089c5b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
Since I updated to the latest Xcode 6 beta, I have been having issues with closing the keyboard. My app is crashing each time I try to close the keyboard, even though I have used the same code for ages and it used to work fine.
Here is what I have:
#IBAction func viewTapped(sender : AnyObject) {
//Closes keyboard when user touches screen.
transactionDateInput.resignFirstResponder()
transactionNameInput.resignFirstResponder()
textField.resignFirstResponder()
notesField.resignFirstResponder()
UIView.animateWithDuration(1.5, animations: {
self.valueEnter.alpha = 0
self.dateEnter.alpha = 0
self.notesDone.alpha = 0
})
}
Someone suggested changing it to something like this:
if (transactionDateInput.isFirstResponder() == true){
transactionDateInput.resignFirstResponder()
}
but that makes no difference. Anyone have any suggestions? Here is the error:
AffordIt[4445:1334424] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AffordIt.SecondViewController textFieldShouldReturn:]: unrecognized selector sent to instance 0x7fb169666880'
Check your Text Field outlet delegate (right click to Text Field)
there should be delegate to your UIViewController!
Look at this tutorial
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'