私はiphoneを初めて使用します。少し疑問があります。つまり、テーブルビューを作成して、すべての本の名前とその特定の本へのダウンロードオプションを次のように各セルに配置しています。
Genesis Download
Exodus Download
Leviticus Download
上記の創世記、出エジプト記、レビ記は本の名前であり、ダウンロードはこのような本をダウンロードするためのボタンです。テーブルビューに66の異なる本があります。ここで私の質問は、ダウンロードボタンをクリックすると、それに対応する本の名前を取得したいです。テーブルビューセル。私のコードは以下のようなものです
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 66;
}
- (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UIButton *downloadButton = nil;
//this is the custom cell i have created one class for this in that i am place the string titlelabel.
CustomCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
downloadButton = [UIButton buttonWithType:UIButtonTypeCustom];
downloadButton.frame = CGRectMake(220,10,50,30);
[downloadButton setImage:[UIImage imageNamed:@"download.png"] forState:UIControlStateNormal];
[downloadButton addTarget:self action:@selector(downloadButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
downloadButton.backgroundColor = [UIColor clearColor];
downloadButton.userInteractionEnabled = YES;
downloadButton.highlighted = YES;
[cell.contentView addSubview:downloadButton];
}
NSString *titleLabel = [[appDelegate getBookNames]objectAtIndex:indexPath.row];
cell.TitleLabel.text = titleLabel;
return cell;
}
-(void)downloadButtonClicked:(id)sender{
}