UIAlertView giving constraint errors - autolayout

i have the following code to present an alert with different messages when problems occur in my app.
the code has worked fine for years, and is in most of my applications on the App Store.
i am making a new app, and simply added this code in, however i am seeing the error messages below in the console, which i can not get rid of.
the constraint message refers to the alert width, but i have no constraints set , and no means to adjust any to silence the warning.
can somebody please advise what's going wrong.
thanks
-(void)errorMessage:(id)sender
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(#"Information",)
message:displaymessage
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *firstAction = [UIAlertAction actionWithTitle:NSLocalizedString(#"OK",)
style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self dismissViewControllerAnimated:NO completion:nil];
}];
[alert addAction:firstAction];
[self presentViewController:alert animated:YES completion:nil];
}
2019-04-18 09:17:54.785207+0100 TestInputView5[1380:28232] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x600001e15b30 UIView:0x7fe60c6104e0.width == - 16 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600001e15b30 UIView:0x7fe60c6104e0.width == - 16 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

I have found a solution on a Russian forum.
It looks like magic, but it works.
You need to do two things:
1) Add an empty view to an Alert
2) Show it without animation
alert.view.addSubview(UIView()) // I can't explain it, but it works!
self.present(alert, animated: false)
Credits to the forum: https://quares.ru/?id=33972
The post is machine-translated, so I suppose there should be an original in English somewhere (I couldn't find it)

Related

How to check if useRouter can use router.back() in nextjs app

I'm using next js for my application and I'm facing some issues with routing to the previous route of the application. I know that there is a function like router.back(), but I do not know if I can go back from the current page.
I have read that we can check history.action !== 'POP' but now I check that history has no action property when using console.log(history)
I am using next/router.
Way too late to be useful but for the next person that comes along: If I read your question correctly, you're wanting to know if there is something in the navigation stack that you can navigate back to - and you want to do something else if there is no history.
You can use window.history.state to get a glimpse; although it doesn't give you clear access to the history stack the state has an "idx" property that is incremented when a location is added to the history stack. This means that if window.history.state.idx is zero there's nothing in the history stack, if it's bigger than zero then there is something in the history stack and you can navigate back.
An example for navigating back if you can or doing something else if not:
if (window.history.state && window.history.state.idx > 0) {
router.back();
} else {
// Do something else
}

Cypress - if function with timeout

I have problem. I want to try to find an element (1) for 60 second timeout. If Cypress will not find it, then it must not end as failed test but click on other element (2) and after that take screenshot and end as failed
It's because if this element (1) is not find it means that some feature in app failed. After I click on second element (2) I will find what was the problem and why it ended like that. That's because I want that screenshot after that.
Is there anyone who knows to resolve this?
I think this should achieve what you are looking for -
cy.get("body").then(($body) => {
// synchronously query for element
if ($body.find("element").length == 0) {
cy.get('locator').click()
cy.screenshot(filename)
}
else {
// do something else
}
})

Swift 4 and Geofire: dealing with invalid geolocation error

I am using the swift 4 language and geofire library to find points on the map within 3000 km of where I am.
When the query encounters the latitude point 90,500 and longitude 100,000 the following error appears: "Not a valid geo location". The crash happens in the "query.observe(.keyEntered" line
query? = geoFire.query (at: self.currentLocation.newLocation !, withRadius: self.distance) {
//code
}
//The crash happens on this line:
var queryHandler = query.observe(.keyEntered, with: {(key, location) in
//Code
})
My question is, how can I handle this kind of error? Do I need to remove all incorrect coordinates from the database? Apparently the function "observe(.keyEntered" does not allow to handle exceptions. I would like to handle the exceptions without the app breaking
It seems like you're hitting the problem described in this issue on the Github repo: https://github.com/firebase/geofire-objc/issues/64
From what I see there, the only option is to reduce the radius of the query.

XPages datagrid not exiting from edit mode

I use dojo.grid.datagrid
If the DataGrid contains lots of rows(example 200) and to scroll, it does not work exit from edit mode cell. Do know what the problem is?
upd: Or maybe someone knows how to use dgrid / gridx in xPages, becouse i found next big bug - encoding after save rest service :(
I just did some testing and I believe I'm seeing the same thing. It seems to be fine to edit and save as I move through the grid. I can scroll down as needed and save changes. However, when I scroll back up and put a cell in edit mode, it doesn't save the changes -- it immediately reverts to the original value. And sometimes it just leaves the cell in edit mode.
I would agree that it seems to be an issue with memory management. If I set the rowsPerPage to a number that will keep all rows in memory, it appears (with very limited testing) that I can scroll up and down and make changes and they're all saved.
I don't have a solution at the moment, but what I would suggest in lieu of a perfect solution is to find a way to set rowsPerPage to a number greater than the amount of rows that will be displayed in the grid. If there's too much data for that to be feasible, then the approach I would take is to provide filtering on the grid to keep the maximum number of rows displayed much lower and then it won't be as much of a performance hit to set the rowsPerPage to a sufficient amount.
If I come across a better solution, I'll come back and post it here.
Yeah! I solved it! :) Error in FileStore.js(extlib). Add this on onClientLoad. I change "!!error code"
restViewItemFileService._processResponse = function(requestObject, data) {
this._items.splice(0, this._items.length); // !!error code -> this.close();
this._start = requestObject.start;
//TODO: clear identity?
dojo.forEach(data.items, function(entry, idx) {
var item = {storeRef:this, attributes:entry};
var id = item.attributes[this._identity]
var pending = this._pendings[id]
if(pending) {
for (var s in pending.modAttrs[s]) {
this.item.attributes[s] = pending.modAttrs[s]
}
}
this._byIdentity[id] = item;
this._items.push(item);
}, this);
this._topLevelEntries = data['#toplevelentries'];
this.onData(requestObject, data);
this._finishResponse(requestObject);
}

Not sure why my program seems to be skipping some functions?

Hey there,
I'm a little confused with some Actionscript I'm working on. For my GUI, I have written four functions for times when computing is taking place. These are showMessage("Loading Text..."), disableButtons(), clearMessage(), and enableButtons(). They work great throughout the program. ShowMessage displays a loading message, disableButtons disables buttons so no one can click anything, clearMessage clears the loading message when job is done, and enableButtons turns them all back on.
For some reason, there is one button click handler which is giving me troubles and I'm not sure why. I've set it up just like others similar to it (which all work) but this one doesn't display the message or shut off my buttons. Here is my clickHandler...
private function Buffer_Route_clickHandler():void
{
showMessage("Loading RBE Options");
disableButtons();
if(Buffer_Route.selected && rbeAC.length == 0){
createRbeAC();
}
}
And here is the creatRbeAC function...
private function createRbeAC():void
{
rbeAC.removeAll();
hiddenRBELayers.removeAll();
var rbeIDs:Array = rbeConfigList.getKeySet();
for each (var rbeID:int in rbeIDs)
{
var rbeConfig:Hashtable = rbeConfigList.find(rbeID) as Hashtable;
var rbeData:Object =
{
restURL:rbeConfig.find("rbeRESTURL") as String,
layername:rbeConfig.find("rbeLayerName") as String,
icon: rbeConfig.find("rbeIcon") as String,
titlefield: rbeConfig.find("rbeTitleField") as String,
checked: rbeConfig.find("rbeChecked") as String,
count: "0" as String
};
if(rbeData.checked == "false")
{
hiddenRBELayers.addItem(rbeData.layername);// as String);
}
rbeAC.addItem(rbeData);
}
}
I wasn't getting any loading text, so I took out my clearMessage and enableButtons functions from the code to see if it was adding the message and disabling the buttons to begin with. I am still not getting anything though. Since clearMessage and enableButtons is no where to be found in this button click handler or creatRbeAC function, then I can not understand why the loading message and buttons aren't disabled, even when the computing is finished.
Some things to note. If I comment out the creatRbeAC function, the loading message shows and buttons do disable. Its almost as if those functions are being ignored when the creatRbeAC function is in the code.
Any help? I would greatly appreciate it. Hopefully I have provided enough information.
in my actual app, i have similiar problems.
In my Eventhandler (it doesn't matter, if there is a button handler or a mouse handler), I also wan't to disable the app and use some filter functions for my arrayCollection.
Unfortunately, this action seems to need too much ressources, especialy, when the app run in debug mode. I have to waint for the next screnn refresh. So i try to implement the "applyFilterMethod" in my eventhandler with
callLater(applyFilterMethod)
but it also wo't work.
Finally, the setTimeOut(applyFilterMethod,500)
solved my issue. So, try it with the timeout-method, if you have luck.
BR
Frank

Resources