私の次のビューコントローラへのセグエを実行するための私の現在のコードは次のとおりです。取得UICollectionViewCellラベルのテキスト
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [arrayOfDescriptions count];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
[[cell IconImage]setImage:[UIImage imageNamed:[arrayOfImages objectAtIndex:indexPath.item]]];
[[cell IconLabel]setText:[arrayOfDescriptions objectAtIndex:indexPath.item]];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"GroupsHomeSegue" sender:self];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"GroupsHomeSegue"])
{
//IconImage is the name of the image in GroupsViewController i want to pass through. Based upon what each cell is set at anyways.
//logoImage is the name of the image i want to set in GroupsHomeViewController.
//so basically i want to be able to get IconImage and set it as logoImage in a different view controller
}
}
私が午前問題は、私が選択した各から私のテキストの値を取得行う方法です私はそれを別のラベルとして詳細なビューコントローラに投稿することができます。
Segueの準備中のコメント行は、私が達成しようとしているものを正確に表しています。私は単なるUICollectionViewCellの値を取得したいと思っています。
これは、以前のビューコントローラの投稿でデータを渡すのと似ているかもしれませんが、これは私が見つけたものとは異なります。テキスト値は定数です。すなわち、label.textの値は1つのものに設定され、配列からは来ません。
個別に選択したセルのラベル値を見つけて詳細なビューコントローラに渡す方法を知りたいだけです。
をコード - 使用してみてください。 –