本文介绍了MonoTouch-访问Obj-C常量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 很多时候,我会阅读Obj-C代码,并需要其中一个常量的值出现在其中一个Obj-C头文件中。Many times I'll read Obj-C code and need the value to one of their constants present in one of the Obj-C header files.用于通知,我已经能够在MonoTouch中找到它们,例如 UIApplication.DidEnterBackgroundNotification 。For notifications, I've been able to find them in MonoTouch such as UIApplication.DidEnterBackgroundNotification.是否存在标准方法获得这样的价值?由于某种奇怪的原因,我需要查找 UINavigationControllerHideShowBarDuration 。Is there a standard way to get such values? I am needing to lookup UINavigationControllerHideShowBarDuration for an odd reason.推荐答案 UINavigationControllerHideShowBarDuration 是 CGFloat ,MonoTouch映射到.NET System.Single ( float (在C#中)。UINavigationControllerHideShowBarDuration is a CGFloat, which MonoTouch maps to a .NET System.Single (float in C#).您应该可以使用 MonoTouch.ObjCRuntime.Dlfcn.GetFloat 方法,以获取 constant 值(它可以在版本之间进行更改,不应像C# const 那样嵌入)运行。例如,You should be able to use MonoTouch.ObjCRuntime.Dlfcn.GetFloat method to retrieve the constant (it could change between versions and should not be embedded like a C# const) value at runtime. E.g.IntPtr handle = Dlfcn.dlopen (Constants.UIKitLibrary, 0);return Dlfcn.GetFloat (handle, "UINavigationControllerHideShowBarDuration"); 这篇关于MonoTouch-访问Obj-C常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-03 13:13