注意:這不是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
有沒有更好或更簡單的方法來做到這一點?如果沒有,任何人都可以提出我目前的做法有誤嗎?