以编程方式在iPhone SDK中打开蓝牙?

我已经看到很多与此有关的问题,但是没有人真正给出真正的答案(要导入的框架,实际代码等)。他们只会说一个私有的api,这会使您的应用程序被应用程序商店拒绝。

我知道使用私有api将使我的应用程序被拒绝,因为我想知道如何将其用于个人使用。(iPhone SDK 3.1.2,iPod touch 2g)


白衣染霜花
浏览 670回答 3
3回答

慕田峪4524236

您需要确保二进制文件和头文件都在PrivateFrameworks文件夹下:/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/System/Library/PrivateFrameworks这将使您可以将诸如BluetoothManager.framework之类的PrivateFrameworks导入您的应用程序,而不会出错。您可以找到如何在线获取标题。这适用于3.1.2,因为我现在正在编写一个可以在我的设备以及Sim上完美运行的应用程序。如果要在模拟器中进行测试,请使用以下命令:#if TARGET_IPHONE_SIMULATOR        //This is where simulator code goes that use private frameworks#else        /* this works in iOS 4.2.1 */        Class BluetoothManager = objc_getClass("BluetoothManager");        id btCont = [BluetoothManager sharedInstance];        [btCont setPowered:YES];#endif

MMMHUHU

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    // Override point for customization after application launch.#if TARGET_IPHONE_SIMULATOR    exit( EXIT_SUCCESS ) ;#else    /* this works in iOS 4.2.3 */    Class BluetoothManager = objc_getClass( "BluetoothManager" ) ;    id btCont = [BluetoothManager sharedInstance] ;    [self performSelector:@selector(toggle:) withObject:btCont afterDelay:1.0f] ;#endif    return YES ;}#if TARGET_IPHONE_SIMULATOR#else- (void)toggle:(id)btCont{    BOOL currentState = [btCont enabled] ;    [btCont setEnabled:!currentState] ;    [btCont setPowered:!currentState] ;}#endif上述方法将在iOS 4.2.3中工作
打开App,查看更多内容
随时随地看视频慕课网APP