GKPeerPickerController开启手机设置菜单的蓝牙开关

来源:互联网 发布:spearman相关系数 知乎 编辑:程序博客网 时间:2024/06/05 08:31

在我一文章中介绍了通过调出设置界面手动开启蓝牙开关,这一篇介绍下通过GKPeerPickerController开启手机蓝牙开关,不需要切换到Setting界面了.

首先加入GameKit.framework


//.h文件中

#import <GameKit/GameKit.h>

@interface MyViewController : UIViewController<GKPeerPickerControllerDelegate, GKSessionDelegate>{

    GKPeerPickerController *pickerController;

    GKSession *currentSession;

}


//.m文件

-(void)buttonAction:(id)sender{

    pickerController = [[GKPeerPickerController alloc]init];

    pickerController.delegate = self;

    pickerController.connectionTypesMask = GKPeerPickerConnectionTypeNearby;

    [pickerController show];

}

开启蓝牙开关界面


2.点击Turn On 之后的界面(即搜索蓝牙)




总结:

   以上的方法适合于iphone,ipad,iPod 设备间的蓝牙配对.并且文本信息和方式都不能修改.这也是不方便的之处. 

谨慎使用


0 0