0
UICollectionView如何實現didselectitematindexpath,當我選擇一個項目時,給出一個標誌Item,並且它將同時推送到下一個ViewController。當彈出ViewController時,如何識別所選的(預選)項目,如何保留該項目的標誌? 如何上面的描述成真?UICollectionView didselectitematindexpath委託?
UICollectionView如何實現didselectitematindexpath,當我選擇一個項目時,給出一個標誌Item,並且它將同時推送到下一個ViewController。當彈出ViewController時,如何識別所選的(預選)項目,如何保留該項目的標誌? 如何上面的描述成真?UICollectionView didselectitematindexpath委託?
UICollectionViewController有一個屬性clearsSelectionOnViewWillAppear
,默認它的值是YES,那麼在viewWillAppear:
,UICollectionViewController會將所有選定的項目取消選擇。 所以我想這是你需要的。
您還可以在致電[super viewWillAppear:]
之前使用[self.collectionView indexPathsForSelectedItems]
獲取所有選定項目的indexPath(viewWillAppear:
)。
您製作一個'currentSelectedIndex'全局變量,並將其保存在'didSelectItemAtIndexPath'中,並在彈出時將其返回到'viewWillAppear'中。 – gabbler 2014-12-13 02:52:48
對不起,我想要選中的物品變成彩色。如何確定只有一個項目被選中(tincolor)? – 2014-12-13 03:29:03
我相信只能選擇一個項目。 – gabbler 2014-12-13 03:35:24