iphone - How to load a UICollectionViewController on clicking a button in the navigation bar? -


i have class, displayoptviewcontroller, subclass of uicollectionviewcontroller. want display collectionviewcontroller when user clicks button in navigation bar on current page. able load collectionview on button click navigation bar not coming. want user able see button in navigation bar , clicking button should take him current page. tried via storyboard programmatically. when try via storyboard, viewcontroller not displayed , when create view controller object programmatically, not getting navigation bar. idea how to this?

i tried add code viewdidload method in displayoptviewcontroller:

uinavigationbar *navbar=[[uinavigationbar alloc] init]; [[self navigationcontroller] setnavigationbarhidden:no animated:yes]; [self.navigationcontroller.navigationbar addsubview:navbar]; 

but navigation bar still didn't come. kindly help.

update

i loading uicollectionview here

uicollectionviewflowlayout *aflowlayout = [[uicollectionviewflowlayout alloc] init]; [aflowlayout setitemsize:cgsizemake(140, 50)];  [aflowlayout setscrolldirection:uicollectionviewscrolldirectionvertical]; displayoptviewcontroller *vc=[[displayoptviewcontroller alloc] initwithcollectionviewlayout:aflowlayout]; [self presentviewcontroller:vc animated:yes completion:nil]; 

you have few things question,

[self.navigationcontroller.navigationbar addsubview:navbar]; 

you adding navigation bar navigation bar.... instead

[self.navigationcontroller setnavigationbar:navbar]; 

second

[self presentviewcontroller:vc animated:yes completion:nil]; 

you presenting controller.... not pushing/poping it....

[self.navigationcontroller pushviewcontroller:vc animated:yes]; 

try in when programmatically

as storyboard maybe don't have segues set correctly, or properties not set right or something... can't debug this


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -