问题描述
我想试用蓝牙管理器.但是在阅读并测试了这里的所有条目后,我真的很困惑.
I want to try out the BluetoothManager. But I am really confused after reading and testing all the entries here.
首先,我在
Xcode/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/PrivateFrameworks/BluetoothManager.framework
所需的框架.但那里只有二进制文件.所以我添加了一个Headers"文件夹并将 BluetoothManager.h 文件.
the needed Framework. But there was only the binarie file there. So I add a "Headers" folder and put the BluetoothManager.h file in it.
在我的项目中,我添加了这个框架,但它找不到任何BluetoothManager.h文件,所以我得到一个错误,如果我使用
In my project, I add this framework, but it couldn't find any BluetoothManager.h file, so I get an error, if I use
#import "BluetoothManager.h"
或
#import <BluetoothManager/BluetoothManager.h>
我想用下面的代码启动BT:
I want to use the following code to start BT:
- (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] ;
[btCont setPowered:YES] ;
#endif
return YES ;
}
我也尝试过这里的所有想法:
I had tried also all the ideas here:
有没有人有使用 (PrivateFramework/)BluetoothManager 在 iPhone、SKD 5.1 上切换蓝牙的好主意、教程或实际运行示例?
Has any one a realy good idea, a tutorial or a really running example for using (PrivateFramework/)BluetoothManager to toggle Bluetooth on iPhone, SKD 5.1?
非常感谢.
isicom
推荐答案
您可以使用 github 的 class-dump 工具生成头文件
You can generate the header files using class-dump tools from github
或者将以下内容(我为 IOS 5.1 生成)复制/粘贴到 BluetoothManager.h 中,并将该文件添加到您的项目中.那么你应该不会看到错误.
Or copy/paste the below content(I generated for IOS 5.1) into BluetoothManager.h and add that file in your project. Then you should not see the error.
@class NSMutableDictionary;
@interface BluetoothManager : NSObject
{
struct BTLocalDeviceImpl *_localDevice;
struct BTSessionImpl *_session;
int _available;
BOOL _audioConnected;
BOOL _scanningEnabled;
BOOL _scanningInProgress;
unsigned int _scanningServiceMask;
struct BTDiscoveryAgentImpl *_discoveryAgent;
struct BTPairingAgentImpl *_pairingAgent;
struct BTAccessoryManagerImpl *_accessoryManager;
NSMutableDictionary *_btAddrDict;
NSMutableDictionary *_btDeviceDict;
}
+ (id)sharedInstance;
+ (int)lastInitError;
- (BOOL)available;
- (id)init;
- (BOOL)_attach:(id)arg1;
- (BOOL)_setup:(struct BTSessionImpl *)arg1;
- (void)_cleanup:(BOOL)arg1;
- (void)dealloc;
- (void)_postNotificationWithArray:(id)arg1;
- (void)_postNotification:(id)arg1;
- (void)postNotification:(id)arg1;
- (void)postNotificationName:(id)arg1 object:(id)arg2;
- (void)postNotificationName:(id)arg1 object:(id)arg2 error:(id)arg3;
- (int)powerState;
- (BOOL)powered;
- (BOOL)enabled;
- (BOOL)setPowered:(BOOL)arg1;
- (BOOL)setEnabled:(BOOL)arg1;
- (void)_powerChanged;
- (BOOL)isAnyoneScanning;
- (id)addDeviceIfNeeded:(struct BTDeviceImpl *)arg1;
- (void)_removeDevice:(id)arg1;
- (BOOL)wasDeviceDiscovered:(id)arg1;
- (BOOL)deviceScanningEnabled;
- (BOOL)deviceScanningInProgress;
- (void)resetDeviceScanning;
- (void)_scanForServices:(unsigned int)arg1 withMode:(int)arg2;
- (void)scanForServices:(unsigned int)arg1;
- (void)scanForConnectableDevices:(unsigned int)arg1;
- (void)setDeviceScanningEnabled:(BOOL)arg1;
- (void)_restartScan;
- (void)_setScanState:(int)arg1;
- (void)_discoveryStateChanged;
- (BOOL)isDiscoverable;
- (void)setDiscoverable:(BOOL)arg1;
- (BOOL)devicePairingEnabled;
- (void)setDevicePairingEnabled:(BOOL)arg1;
- (void)cancelPairing;
- (void)unpairDevice:(id)arg1;
- (id)pairedDevices:(BOOL)arg1;
- (id)pairedDevices;
- (id)pairedLEDevices;
- (void)setPincode:(id)arg1 forDevice:(id)arg2;
- (void)acceptSSP:(int)arg1 forDevice:(id)arg2;
- (void)connectDevice:(id)arg1 withServices:(unsigned int)arg2;
- (void)connectDevice:(id)arg1;
- (BOOL)connectable;
- (void)setConnectable:(BOOL)arg1;
- (id)connectingDevices;
- (id)connectedDevices;
- (BOOL)_onlySensorsConnected;
- (BOOL)connected;
- (void)_connectedStatusChanged;
- (void)_connectabilityChanged;
- (BOOL)audioConnected;
- (void)setAudioConnected:(BOOL)arg1;
- (void)startVoiceCommand:(id)arg1;
- (void)endVoiceCommand:(id)arg1;
- (BOOL)isServiceSupported:(unsigned int)arg1;
- (void)enableTestMode;
@end
这篇关于iOS 5.1 通过 BluetoothManager 切换蓝牙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!