I am working on a project using Xamarin.iOS and I have a situation where a behavior in the simulator inexplicably is not the same on an actual device (setting the region of a mapview centers differently).
I want to be able to set a value for a variable at runtime based on whether the app is running on the simulator or a real device. How can I detect this?
You can execute different code at runtime like this:
if (ObjCRuntime.Runtime.Arch == Arch.DEVICE) {
} else {
}
But it's always good to investigate (ask around here, forums, bug reports) why the behaviour differs between the two (just to make sure it does not hide a bug that could bite you later).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With