//首先在viewdidload写个方法
-(void)collectionView:(UICollectionView*)collectionView didSelectItemAtIndexPath:(NSIndexPath*)indexPath{
NSLog(@"第%ld分区---第%ld行",indexPath.section,indexPath.row);
NewViewController *new = [[NewViewController alloc]init];
NSString*str =_dic.allKeys[indexPath.section];
NSString*name = [[[_dicobjectForKey:str]objectAtIndex:indexPath.row]allKeys][0];
new.name= name;
new.img= [UIImageimageNamed:[[_dicobjectForKey:str]objectAtIndex:indexPath.row][name]];
[self presentViewController:new animated:YES completion:nil];
}
//然后创建一个新的页面,.h写上name,image属性
//然后在.m写内容
-(UIImageView*)imageView{
if (!_imageView) {
_imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-50)];
}
return _imageView;
}
-(UILabel*)label{
if(!_label) {
_label= [[UILabelalloc]initWithFrame:CGRectMake(200,self.view.frame.size.height-40,200,30)];
}
return _label;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
[self.viewaddSubview:self.imageView];
[self.viewaddSubview:self.label];
self.imageView.image = self.img;
self.label.text=self.name;
}
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event{
[self dismissViewControllerAnimated:YES completion:nil];
}