注意:这不是App Store的应用程序,所以使用私有API不是我关心的问题。切换飞行模式monotouch xamarin
我一直在试图切换飞行模式并重新开启使用Xamarin/MonoTouch的基于关闭此SO问题:How to turn on/off airplane mode in IOS 5.1 using private API
我有一个很难得到这个代码在运行MonoTouch的 - 第一件事我尝试的是使用monotouch绑定项目创建本机客户C库。
的AppSupport框架使用,因此我linkwith文件如下:
[assembly: LinkWith ("libAirplaneModeLib.a", LinkTarget.ArmV7, ForceLoad = true, Frameworks = "AppSupport")]
当我做到这一点,编译,但我无法从我的主要项目中引用的命名空间。如果我不包括框架如下:
[assembly: LinkWith ("libAirplaneModeLib.a", LinkTarget.ArmV7, ForceLoad = true)]
在这种情况下,我可以参考的命名空间,但主要项目编译与链接:
"_OBJC_CLASS_$_RadiosPreferences", referenced from:
objc-class-ref in libAirplaneModeLib.a(AirplaneModeLib.o)
ld: symbol(s) not found for architecture armv7
collect2: ld returned 1 exit status
error MT5202: Native linking failed. Please review the build log.
我ApiDefinition文件如下:
[BaseType(typeof(NSObject))]
public interface AirplaneModeLib
{
[Export("toggleAirplane")]
void ToggleAirplane();
}
本地库如下:
#import "AirplaneModeLib.h"
#import "RadiosPreferences.h"
@implementation AirplaneModeLib
- (void) toggleAirplane {
RadiosPreferences* preferences = [[RadiosPreferences alloc] init];
preferences.airplaneMode = NO;
[preferences synchronize];
preferences.airplaneMode = YES;
[preferences synchronize];
[preferences release];
}
@end
有没有更好或更简单的方法来做到这一点?如果没有,任何人都可以提出我目前的做法有误吗?