xcode - NSCollectionView: Go to the next view on selection with Selected Item -
i new os x , have started dealing nscollectionview. trying take show nscollectionview array of imageview labels. , on selection of image want open new viewcontroller class. able show array of images , labels in collection view lost on how go new view selection made in nscollectionview , how show image selected new viewcontroller class.
i having nstabview , in having customview in showing collectionview. , in awakefromnib doing populate collectionview
-(void)awakefromnib { arritems = [[nsmutablearray alloc]init]; nsmutablearray *imagearray=[[nsmutablearray alloc]initwithobjects:@"baby-girl-wallpaper-2012-7.jpg",@"cute-little-baby-girl.jpg",@"joker_hd_wallpaper_by_riddlemethisjoker.jpg",@"the-dark-angel-wallpaper-hd.jpg",@"hd-wallpapers-1080p_hdwallpapersarena_dot_com.jpg",@"lion_hd_wallpaper.jpg",@"ganesh_painting.jpg",@"krishna-wallpaper.jpg",@"leon_userpic_79630_fire_lion_by_alex_barrera.jpg",@"273483.png",@"japan_digital_nature-wide.jpg", nil]; nsmutablearray *imagename = [[nsmutablearray alloc]initwithobjects:@"baby-girl",@"cute-little",@"joker",@"the-dark",@"hd-wallpapers", @"lion", @"ganesh", @"krishna", @"leon_userpic",@"273483.png",@"japan_digital", nil]; for(int = 0; i<[imagearray count]; i++) { stimagecollectionmodal * img1 = [[stimagecollectionmodal alloc] init]; img1.image = [nsimage imagenamed:[imagearray objectatindex:i]]; img1.imagename = [nsstring stringwithformat:@"%@",[imagename objectatindex:i]]; [arritems addobject:img1]; } [collectionview setcontent:arritems]; }
later created new class named "stcollectionview" subclass of nscollectionview , assigned collectionview class "stcollectionview" , of setselectionindexes method tried getting index of selected item this
- (void)setselectionindexes:(nsindexset *)indexes nslog(@"%ld",[indexes firstindex]);
but method getting called twice , whenever put "super setselectionindexes" gives me garbage value. searching on unable find kind of solution. please help..
thank in advance.
your question confusing me.what thinking can task adding uicollectionview , in uicollectionview
add custom uicollectionviewcell
.in custom uicollectionviewcell add uiimageview
, uilabel
. in method
- (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath{ static nsstring *identifier = @"reuseid"; uicollectionviewcell *cell = [collectionview dequeuereusablecellwithreuseidentifier:identifier forindexpath:indexpath]; cell.imageview.image = [uiimage imagewithnmaed:@"your image name"]; cell.label.text = @"image named"; return cell; }
and in storyboard hold clt+drag uiviewcontroller
.in method prepareforsgue method pass data next viewcontroller.