查看 Apple Developer Reference,我发现它PreferredLocalizations
可以作为PreferredLanguages
:
但是,似乎“PreferredLocalizations”没有在NSBundle
. 我在这里错过了什么吗?我是using MonoTouch.Foundation
查看 Apple Developer Reference,我发现它PreferredLocalizations
可以作为PreferredLanguages
:
但是,似乎“PreferredLocalizations”没有在NSBundle
. 我在这里错过了什么吗?我是using MonoTouch.Foundation
You're right, it's presently missing from MonoTouch. The best and fastest way to get it is to fill a bug report and ask for it.
In many cases (like this one) it's easy to give a workaround that will work with existing releases of MonoTouch.
Note that your link is for OSX, not iOS and some types, including NSBundle
have a few differences between the two (but in the case of preferredLocalizations
it exists in both OS).
UPDATE
I added this for the next (it will be 5.3.5) version of MonoTouch. In the meantime here's a workaround:
using MonoTouch.ObjCRuntime;
...
var bh = NSBundle.MainBundle.Handle;
var sel = Selector.GetHandle ("preferredLocalizations");
var pl = NSArray.StringArrayFromHandle (Messaging.IntPtr_objc_msgSend (bh, sel));
Console.WriteLine (pl [0]); // en