0
值我需要幫助編碼我prepareForSegue:
prepareForSegue比較來自陣列和字典
這TeamObject
持有teamID
值,也可以是,55 ... 65 ...等。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"StandingsIdent";
StandingsViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
TeamObject *item = [tableData objectAtIndex:[indexPath row]];
long row = [indexPath row];
if ([item isKindOfClass:[TeamObject class]]) {
cell.cellTeamName.text = item.teamName;
cell.cellTeamLogo.image = item.teamLogo;
cell.cellPlayed.text = item.matchesPlayed;
cell.cellWins.text = item.wins;
cell.cellTies.text = item.ties;
cell.cellLoses.text = item.loses;
cell.cellPoints.text = item.points;
cell.cellTeamPosition.text = _teamPosition[row];
cell.cellInfo.text = _infoLeague[row];
}
else {
}
我viewDidLoad中,有幾個字典,持有鑰匙的每個對象:
- (void)viewDidLoad {
[super viewDidLoad];
_testThis = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"2", @"1478.png",
@"3", @"1487.png",
@"4", @"1489.png",
@"5", @"1494.png",
@"6", @"1474.png",
@"7", @"2390.png",
@"8", @"2433.png",
@"9", @"1488.png",
@"10", @"1481.png",
@"11", @"2383.png",
@"12", @"1476.png",
@"13", @"1495.png",
@"14", @"729500.png",
@"15", @"2386.png",
@"16", @"2445.png",
@"17", @"2393.png",
nil];
現在我需要我的prepareForSegue
做這個邏輯,如果在TeamObject
teamId
,匹配團隊ID在字典中,發送信息槽...
我把它編碼的方式是靜態的,我的團隊每天都會更換位置,所以我需要這個segue在顯示其他信息時知道他在做什麼。
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([[segue identifier] isEqualToString:@"teamDetailsSeg"]){
TeamDetailsTableViewController *detailViewController = [segue destinationViewController];
NSIndexPath *myIndexPath = [self.tableView indexPathForSelectedRow];
long row = [myIndexPath row];
if ([TeamObject o
detailViewController.teamDetailModel = @[_teamFullNames[row], _teamLogos[row], _teamStadiumPictures[row], _teamStadiumNames[row], _stadiumCapacity[row], _stadiumBuiltYear[row], _clubFoundationDate[row], _teamCity[row], _clubPresident[row], _headCoach[row], _championshipsWon[row], _domesticCupsWon[row], _domesticLeagueCupsWon[row], _domesticSuperCupsWon[row], _championsleaguesWon[row], _europaleaguesWon[row], _europeanSuperCupsWon[row], _worldclubchampionshipsWon[row]];
}
}
這是我ExtraDetailsViewController
代碼,一切正常,但它是靜態的,所以如果明天球隊在第1名下降到第2,額外附加的數據是不正確的。
- (void)viewDidLoad
{
[super viewDidLoad];
_cellFullTeamName.text = _teamDetailModel[0];
_cellTeamLogo.image = [UIImage imageNamed:_teamDetailModel[1]];
_cellTeamStadium.image = [UIImage imageNamed:_teamDetailModel[2]];
_cellStadiumName.text = _teamDetailModel[3];
_cellStadiumCapacity.text = _teamDetailModel[4];
_cellStadiumYear.text = _teamDetailModel[5];
_cellClubYear.text = _teamDetailModel[6];
_cellStadiumCity.text = _teamDetailModel[7];
_cellPresident.text = _teamDetailModel[8];
_cellCoach.text = _teamDetailModel[9];
_cellDomesticChampionships.text = _teamDetailModel[10];
_cellDomesticCups.text = _teamDetailModel[11];
_cellDomesticLeagueCups.text = _teamDetailModel[12];
_cellDomesticSupercups.text = _teamDetailModel[13];
_cellChampionsLeagues.text = _teamDetailModel[14];
_cellEuroLeagues.text = _teamDetailModel [15];
_celLEuroSuperCups.text = _teamDetailModel[16];
_cellIntertoto.text = _teamDetailModel [17];
}
任何人都可以幫忙嗎?
謝謝。
我需要在prepareforsegue方法中添加代碼 – user3295409