2013-05-25 13 views

回答

1

你可以很容易地做到這一點。到目前爲止,你的想法是在正確的方向。將數據保留在數組中(使用字典會更好,因爲您可以避免使用兩個不同的數組並獲得良好的結構)並跟蹤所選項目的索引。

您已在detailViewController中創建一個屬性來存儲選定的項目編號。

- (void)collectionView:(PSUICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 
{ 

    DetailViewController *detailViewController = [[DetailViewController alloc]init]; 
    detailViewController.selectedItem = indexPath.row; 
    [self.navigationController pushViewController:detailViewController animated:YES]; 

    [detailViewController release]; 
} 
+0

乾杯的信息。 – maxn00b

+0

想一想,是否有可能從'didselect'方法獲得一個nsinteger,然後以某種方式在'prepareforsegue'方法中使用它? – maxn00b

+0

雅是有可能的..要麼你可以將indexPath.row存儲在didSelectRow的實例變量中,要麼你可以直接從prepareForSegue中調用indexPathForSelectedRow –

相關問題