IOS开发使可视单元格可点击
我刚刚开始IOS开发,不知道是否有人能帮我弄清楚如何获取正在点击的手机的详细信息 我有一个这样的手机:IOS开发使可视单元格可点击,ios,uicollectionview,Ios,Uicollectionview,我刚刚开始IOS开发,不知道是否有人能帮我弄清楚如何获取正在点击的手机的详细信息 我有一个这样的手机: #import <UIKit/UIKit.h> @interface ICICell : UICollectionViewCell @property (weak, nonatomic) IBOutlet UILabel *myLabel; @property (weak, nonatomic)IBOutlet ICICell *myCell; @property (weak,
#import <UIKit/UIKit.h>
@interface ICICell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UILabel *myLabel;
@property (weak, nonatomic)IBOutlet ICICell *myCell;
@property (weak, nonatomic) IBOutlet UIImageView *myGallery;
@end
-(UICollectionViewCell * ) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
ICICell * aCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"myCell" forIndexPath:indexPath];
aCell.myLabel.text = self.dataArray[indexPath.row];
UIImage *img;
long row = [indexPath row];
img = [UIImage imageNamed:self.iciImages[row]];
aCell.myGallery.image = img;
return aCell;
}
我已经找到了didSelectItemAtIndexPath方法,但是是否有didSelectItemAtIndexPath方法
我正在尝试获取选定单元格的标签文本。有点困惑为什么有一个didSelect和没有didSelect?提前谢谢。琳达·基廷
正如您所期望的,这两种方法都是可用的。请从下面获得参考
谢谢。当然,您可以导航到集合视图单元格的详细信息屏幕 只需使用
didSelectItemAtIndexPath
方法
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
VIPRoomDetailController *enterIntoRoomDetail = [[VIPRoomDetailController alloc]initWithNibName:@"VIPRoomDetailController" bundle:nil];
[self.navigationController pushViewController:enterIntoRoomDetail animated:YES];
}
同样在集合视图类中导入细节控制器在我的例子中是
VIPRoomDetailController
简单回答:是的,您正在寻找的方法存在。你查过了吗?你看过文档了吗?你说的“没有didSelect方法”是什么意思?有一个。我必须承认我只是很快地搜索了一下,没有找到它。我认为XCode并没有在代码完成中提出这一点,这是一个糟糕的假设。谢谢-我现在找到了。这是当你在谷歌上搜索“clickable UICollectionViewCell”时出现的第一个链接,有趣的是堆栈是如何工作的
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
VIPRoomDetailController *enterIntoRoomDetail = [[VIPRoomDetailController alloc]initWithNibName:@"VIPRoomDetailController" bundle:nil];
[self.navigationController pushViewController:enterIntoRoomDetail animated:YES];
}