//首先在viewdidload寫個方法
-(void)collectionView:(UICollectionView*)collectionView didSelectItemAtIndexPath:(NSIndexPath*)indexPath{
? ? NSLog(@"第%ld分區(qū)---第%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];
}
//然后創(chuàng)建一個新的頁面,.h寫上name,image屬性
//然后在.m寫內(nèi)容
-(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];
}