为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

白衣染霜花 2019-10-09 17:52:28
我已经看到很多与此有关的问题,但是没有人真正给出真正的答案(要导入的框架,实际代码等)。他们只会说一个私有的api,这会使您的应用程序被应用程序商店拒绝。我知道使用私有api将使我的应用程序被拒绝,因为我想知道如何将其用于个人使用。(iPhone SDK 3.1.2,iPod touch 2g)
查看完整描述

3 回答

?
慕田峪4524236

TA贡献1875条经验 获得超5个赞

您需要确保二进制文件和头文件都在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


查看完整回答
反对 回复 2019-10-09
?
MMMHUHU

TA贡献1834条经验 获得超8个赞

- (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中工作


查看完整回答
反对 回复 2019-10-09
  • 3 回答
  • 0 关注
  • 659 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信