Je développe l'application Bluetooth.J'ai un nom de périphérique Bluetooth disponible dans Table View..Si appuyer sur un périphérique signifie que je veux connaître tous les services UUID pris en charge dans un autre contrôleur de vue avec vue Table.Give moi une idée.Comment afficher les services pris en charge de Bluetooth dans tableview à partir du nom de périphérique (UITableViewCell)?
1) Peripheralmanager (NSObject)
2) FirstViewController (Dans ce que j'ai un nom de périphérique)
3) SecondViewController (Dans ce que je veux Services pris en charge)
Peripheralmanager.m
- (void)centralManager:(CBCentralManager *)central
didDiscoverPeripheral:(CBPeripheral *)peripheral
advertisementData:(NSDictionary *)advertisementData
RSSI:(NSNumber *)RSSI
{
NSLog(@"didDiscoverPeriphera.peripheral: %@ rssi: %@, UUID:%@ advertisementData:%@", peripheral,RSSI,peripheral.UUID, [advertisementData description]);
targetPeripheral = peripheral;
peripheral.delegate = self;
if (!peripheral.isConnected)
{
[centralManager connectPeripheral:peripheral options:nil];
}
}
FirstViewCo ntroller.m
- (void)peripheralManagerDidConnectPeripheral:(PeripheralManager *)peripheral
{
NSLog(@"%@",peripheral.deviceName);
NSLog(@"%@",peripheral.rssi);
[device addObject:[NSString stringWithFormat:@"%@",peripheral.deviceName]];
[self.deviceTable reloadData];
}
Tableview
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *[email protected]"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if(cell==nil)
{
cell =[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text=[device objectAtIndex:indexPath.row];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
Si vous voulez plus d'informations S'il vous plaît Demandez-moi.
S'il vous plaît Vérifiez ce lien sample Itunes app
l'image
avez-vous trouvé la réponse que j'essaie de faire la même chose –