在UIViewController 1
中,我设置了一个数组。此UIViewController
代表UIViewController 2
。
在UIViewController 2
中,有UITableView
个自定义UITableViewCell
。还有一个UIButton
可以很好地回到UIViewController 1
。
在自定义单元格中,有一个collectionView
。这是由ViewController 1
。
我的问题是,当collectionView
(UIViewController 2
- 自定义UITableViewCell
类)中的某个项目被选中时,如何将该值一直传递回UIViewController 1
?
如果这是重复的话,我很抱歉。我在这里提到了许多类似的条目,但似乎没有任何工作。我也试过这个:
http://www.appcoda.com/ios-collection-view-tutorial/
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showRecipePhoto"]) {
NSArray *indexPaths = [self.collectionView indexPathsForSelectedItems];
RecipeViewController *destViewController = segue.destinationViewController;
NSIndexPath *indexPath = [indexPaths objectAtIndex:0];
destViewController.recipeImageName = [recipeImages[indexPath.section] objectAtIndex:indexPath.row];
[self.collectionView deselectItemAtIndexPath:indexPath animated:NO];
}
}
我一直得到返回的空值,我不知道为什么。
(我不是在使用故事板。这是我第一次尝试任何类型的编程。非常感谢任何输入!)
答案 0 :(得分:0)
答案 1 :(得分:0)
You can use clipboardData
.
Add in your class:
copy
and use document.addEventListener('copy', (event) => {
// event.clipboardData.?
// maybe event.clipboardData.setData(?)
})
this event is called when the cell is selected; you must save the value in a property; like that:
UICollectionViewDelegate
and then:
class YourViewController: UIViewController, UICollectionViewDelegate { ... }