i'm creating single view application using cocoa touch. need menu appear selection of different themes single view, , ive been wondering best approach is, , how achieve that.
should create master-detail view? , if how detail view initial screen app loads. i'm not sure if best approach take.
ive been looking @ things pop on menu, id rather learn how achieve kind of thing myself, buy off shelf solution. there class in cocoa touch offers similar functionality? have built menu scratch using core graphics, there easier way achieve type of menu, perhaps using group of uibuttons example?
code examples appreciated, looking best way tackle problem, know frameworks familiarize myself with.
tia
you try using uicollectionview uicollectionviewflowlayout create grid of buttons used switch between different themes.
without knowing more want out of selection menu, how many themes have, how want display etc. it’s difficult suggest 1 method on another. because uicollectionviewflowlayout pre-defined uicollectionviewlayout provided apple display uiviews in grid arrangement, way of tackling problem.
here how implement uicollectionview uicollectioviewflowlayout:
header file
@interface viewcontroller : uiviewcontroller <uicollectionviewdatasource,uicollectionviewdelegateflowlayout> { uicollectionview * themeselection; } implementation file
- (void)viewdidload { uicollectionviewflowlayout *layout=[[uicollectionviewflowlayout alloc] init]; themeselection =[[uicollectionview alloc] initwithframe:self.view.frame collectionviewlayout:layout]; [themeselection setdatasource:self]; [themeselection setdelegate:self]; [themeselection registerclass:[uicollectionviewcell class] forcellwithreuseidentifier:@"cellidentifier"]; [self.view addsubview: themeselection]; [super viewdidload]; } - (nsinteger)collectionview:(uicollectionview *)collectionview numberofitemsinsection:(nsinteger)section { return 15; } - (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { uicollectionviewcell *cell=[collectionview dequeuereusablecellwithreuseidentifier:@"cellidentifier" forindexpath:indexpath]; //each cell theme selected return cell; } - (cgsize)collectionview:(uicollectionview *)collectionview layout:(uicollectionviewlayout*)collectionviewlayout sizeforitematindexpath:(nsindexpath *)indexpath { return cgsizemake(100, 100); }
Comments
Post a Comment