私の質問は、テキストデータを取得し、セルがタップされたときに私のViewControllerで読むことが可能ですか?UITableView - タップ時にデータを取得
私はdidSelectRowAtIndexPath
がこれを行う鍵だと推測していますが、私はどのように書くべきかわかりません。
私は以下のようにPHPから私のTableViewController
にデータを取得することができます。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [json count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSDictionary *info = [json objectAtIndex:indexPath.row];
cell.textLabel.text = [info objectForKey:@"Artist"];
cell.detailTextLabel.text = [info objectForKey:@"Song"];
return cell;
}
はいメソッドを選択して、そのメソッドでRetriveデータコードを書き込むことができます。配列前に必要な場合はテーブルビューをリロードするか、新しいView Controllerを呼び出してそこに渡します。 – vishiphone