0

我建立了一個當地的足球俱樂部的應用程序的按鈕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。有人知道我該怎麼做?

親切的問候。

回答

0

這是錯誤的方式來實現你想要做什麼。查找照片瀏覽器,如Three20(以Three20作爲一個例子,它是舊的,沒有ARC,並有上的Git更好的替代品)和Segue公司根據每個球員的照片的選擇一個新的觀點。

如果你真的想要(儘管它看起來像設計不佳的IMO),你可以連接6個按鈕並標記它們,然後根據所選的按鈕標籤選擇一個播放器,但這看起來並不是最好的選擇的UITableView的

相關問題