我建立了一個當地的足球俱樂部的應用程序的按鈕SEGUE。在屏幕上,我想顯示所有球員在一個網格。當你點擊網格內的球員照片時,你會得到關於該球員的更多信息。 我正在使用customTableViewCell。這個tableView單元格包含6個按鈕。每個按鈕後面都有一些播放器信息。我正在像這樣在網格中設置玩家圖像。首先我在我的custumTableViewCell中有一個方法。如何從一個自定義tableviewCell
-(void)setImage:(UIImage *)image forPosition:(NSUInteger)position{
if(position == 1){
[_btnPlayer1 setImage:image forState:UIControlStateNormal];
}else if(position == 2){
[_btnPlayer2 setImage:image forState:UIControlStateNormal];
}else if(position == 3){
[_btnPlayer3 setImage:image forState:UIControlStateNormal];
}else if(position == 4){
[_btnPlayer4 setImage:image forState:UIControlStateNormal];
}else if(position == 5){
[_btnPlayer5 setImage:image forState:UIControlStateNormal];
}else if(position == 6){
[_btnPlayer6 setImage:image forState:UIControlStateNormal];
}
}
而在我的CellForRowAtIndexPath我做了以下。
NSInteger frcRow = indexPath.row * IMAGES_PER_ROW; // row in fetched results controller
for (int col = 1; col <= IMAGES_PER_ROW; col++) {
NSIndexPath *path = [NSIndexPath indexPathForRow:frcRow inSection:0];
Team *team = [self.fetchedResultsController objectAtIndexPath:path];
NSData *imgData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:team.image]];
UIImage *image;
if (imgData == nil) {
// default image
image = [UIImage imageWithContentsOfFile:@"keeperNil.jpg"];
} else {
image = [UIImage imageWithData:imgData];
}
[cell setImage:image forPosition:col];
frcRow ++;
}
return cell;
但是現在我想確定哪個按鈕被按下,然後繼續顯示正確信息的detailViewController。有人知道我該怎麼做?
親切的問候。