编程开启蓝牙在iPhone SDK? [英] Programmatically turn on bluetooth in the iphone sdk?

查看:328
本文介绍了编程开启蓝牙在iPhone SDK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了很多关于这个问题,但没有人真正给出了真正的答案(框架导入,实际code等)。他们只能用私有API称,这将让你的应用程序从App Store拒绝。

I have seen a lot of questions about this but no one actually gives a real answer (frameworks to import, actual code etc). They only say with a private api and that will get your app rejected from the app store.

据我所知,使用私有API的会得到我的应用程序拒绝了我不知道该怎么办呢供个人使用。 (iPhone的SDK 3.1.2,iPod touch的2G)

I am aware that use of a private api will get my app rejected by I was wondering how to do it for personal use. (iPhone SDK 3.1.2, iPod touch 2g)

推荐答案

我一直在寻找到这一点。您需要在您的项目bluetoothmanager框架和头文件。它的的是

I've been looking into this as well. You need to include the bluetoothmanager framework and header file in your project. It should be in

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/PrivateFrameworks/BluetoothManager.framework/

如果头文件不存在,你需要抓住一个从库中产生的,包括在您的项目.h文件。我用Google搜索找到它;这是一个在这里:

If the header file is not there, you'll need to grab a .h file that was generated from the library and include it in your project. I googled to find it; Here is one here:

<一个href=\"http://iphone-dev.google$c$c.com/svn/branches/include-1.2-sdk/include/BluetoothManager/\">http://iphone-dev.google$c$c.com/svn/branches/include-1.2-sdk/include/BluetoothManager/

一旦被添加到你的项目,你的进口应该是这样的,如果头文件已经在框架:

Once that is added to your project, your import should look like this if the header file was already in the framework:

#import <BluetoothManager/BluetoothManager.h>

或者这样,如果您添加自己的BluetoothManager.h文件到您的项目:

Or this if you added your own BluetoothManager.h file to your project:

#import "BluetoothManager.h

要在这里切换蓝牙是code:

To toggle the bluetooth here is the code:

BluetoothManager *manager = [BluetoothManager sharedInstance];
[manager setEnabled:![manager enabled]];    

我建立了一个工具来这做我自己和它的工作。请注意,如果你想要做的就是创建一个实用程序切换蓝牙和退出,没有任何UI,打造X code上新建一个项目,并使用基于窗口 - 应用模板。在code添加到didFinishLaunchingWithOptions方法和替换 [窗口makeKeyAndVisible] 退出(0)

I have built a utility to do this myself and it does work. Note, if all you want to do is create a utility to toggle the bluetooth and exit, without any UI, create a new project in XCode and use the Window-based Application template. Add the code to the didFinishLaunchingWithOptions method and replace [window makeKeyAndVisible] with exit(0).

这篇关于编程开启蓝牙在iPhone SDK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆