私はBluetoothアプリを開発しています.1)アプリを起動したときにテーブルビューを非表示にしたい..アクションボタンを押した後、テーブルビューを有効にしたい..2)アクションボタンをもう一度押すと、テーブルビューセルがクリアされます.検索する前にデータと表示が空です..アイデアを教えてください..
コードの一部-
- (IBAction)connectButtonTouched:(id)sender
{
[self.deviceTable reloadData];
self.connectButton.enabled = YES;
[self.deviceTable reloadData];
peripheralManager = [[PeripheralManager alloc] init];
peripheralManager.delegate = self;
[peripheralManager scanForPeripheralsAndConnect];
[self.deviceTable reloadData];
[NSTimer scheduledTimerWithTimeInterval:(float)5.0 target:self selector:@selector (connectionTimer:) userInfo:nil repeats:YES];
alert=[[UIAlertView alloc] initWithTitle:@"Bluetooth" message:@"Scanning" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
UIActivityIndicatorView *progress=[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125, 50, 30, 30)];
[alert addSubview:progress];
[progress startAnimating];
[alert show];
}
テーブルビュー
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [device count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier=@"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell==nil)
{
cell =[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text=[device objectAtIndex:indexPath.row];
cell.accessoryType=UITableViewCellAccessoryDetailDisclosureButton;
return cell;
}
TableView デリゲート
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];
[self performSegueWithIdentifier:@"TableDetails" sender:tableView];
}